def check_gpus(args, tmpdir): """ check for CUDA capable GPUs :args: parsed cmdline args :tmpdir: temporary directory :returns: dict with GPU info """ if args.no_gpu: LOG.warning("Not scanning available gpus, running programs will fail") return {'num_gpus': 0, 'gpu_info': []} LOG.info('Checking CUDA build system') program = setup_cuda_detect(args, tmpdir) res = { 'num_gpus': program.get_num_gpus(), 'gpu_info': [], } for gpu_index in range(res['num_gpus']): props = GPUProps() program.get_gpu_data(gpu_index, ctypes.byref(props)) gpu_info = { 'gpu_index': props.gpu_index, 'comp_level_major': props.comp_level_major, 'comp_level_minor': props.comp_level_minor, 'sm_count': props.sm_count, 'max_sm_threads': props.max_sm_threads, 'max_sm_blocks': props.max_sm_blocks, 'max_block_size': props.max_block_size, 'max_total_threads': props.max_total_threads, 'max_total_blocks': props.max_total_blocks, 'name': props.name.decode(), } gpu_info['reasonable_block_size'] = get_reasonable_block_size(gpu_info) res['gpu_info'].append(gpu_info) return res
def _normalize_server_args(args): """normalize server arguments""" # ensure port number is valid if args.port > 65535: LOG.error('port number invalid: %s', args.port) return None elif args.port < 1024: LOG.warning('port number requires root priv: %s', args.port) # NOTE: does not support ipv6 bind addrs and may allow some invalid addrs if len(args.host.split('.')) != 4: LOG.error('invalid bind addr: %s', args.host) return None return args
def handle(self): """ Handle event using handler defined in event handler map and set result """ if self.event_handler_map is None: raise NotImplementedError("Cannot handle BaseEvent") handler = self.event_handler_map.get( self.event_type, handler_not_implemented) start_time = time.time() try: self.status = EventStatus.RUNNING self.result = handler(self) self.status = EventStatus.SUCCESS except Exception as e: msg = repr(e) LOG.warning("Failed to complete event: %s error: %s", self, msg) self.status = EventStatus.FAILURE self.result = {'error': msg} end_time = time.time() self.completion_time = end_time - start_time
try: <<<<<<< HEAD res = client.get(endpoint, params, expect_json=expect_json) res_success[client_uuid] = res except OSError: failed_clients.append(client_uuid) return res_success, failed_clients def post_all(self, endpoint, data, expect_json=True): ======= res = client.get( endpoint, params, expect_json=expect_json, callback_func=callback_func) res_success[client_uuid] = res except OSError: LOG.warning("Client failed event") failed_clients.append(client_uuid) self._register_multi_callback_from_remote( res_success, multi_callback_func) return res_success, failed_clients def post_all( self, endpoint, data, expect_json=True, callback_func=None, multi_callback_func=None): >>>>>>> ef9b13b186c1a356f50a36e78ad91a3ccff76392 """ make a POST request to all clients, does not raise for bad status code :endpoint: client api endpoint :data: data to post as json, must be dict :expect_json: if true, decode client responses as json <<<<<<< HEAD
def build( self, cuda_bin=None, include_path=None, unpack=True, set_compute_level=True): """ set up user program resources and build shared obj :cuda_bin: path to cuda tools bin :include_path: path to cuda include dir :unpack: if true, unpack program json :set_compute_level: if true, specify appropriate compute level """ if not self.build_dir or not os.path.isdir(self.build_dir): raise ValueError("Build dir not set up") if unpack: files = ['cuda', 'python', 'header'] if self.use_c_extention: files.append('cpp') self.unpack(files) build_files = ['Makefile'] if self.use_c_extention: build_files.append('setup.py') self.copy_build_files(build_files) make_cmd = ['make', '-C', self.build_dir] if cuda_bin is not None: nvcc_path = os.path.join(cuda_bin, 'nvcc') make_cmd.append('NVCC={}'.format(nvcc_path)) if include_path is not None: make_cmd.append('CUDA_L64=-L{}'.format(include_path)) if set_compute_level: flag_value = '-arch={}'.format(self.compute_level) make_cmd.append('COMPUTE_LEVEL_FLAG={}'.format(flag_value)) LOG.debug('Using compute level: %s', flag_value) else: LOG.warning('Using default compute level, not optimized') LOG.debug('Building CUDA shared object') util.subp(make_cmd) if self.use_c_extention: LOG.debug('Building Python wrapper module') # XXX # FIXME create hardcoded tmp dir used by dynamic linker shared_dll = 'user_program_cuda.so' tmp_dir = '/tmp/lizard-slayer/' pathlib.Path(tmp_dir).mkdir(exist_ok=True) for the_file in os.listdir(tmp_dir): file_path = os.path.join(tmp_dir, the_file) if os.path.isfile(file_path): os.unlink(file_path) elif os.path.isdir(file_path): shutil.rmtree(file_path) setup_cmd = ['python3', 'setup.py', 'build_ext', '-b', tmp_dir] util.subp(setup_cmd, cwd=self.build_dir) # copy over the shared library to be found by the linker shutil.copyfile(os.path.join(self.build_dir, shared_dll), os.path.join(tmp_dir, shared_dll)) # FIXME remove path sys.path.append(tmp_dir) sys.path.append(self.build_dir) self.ready = True else: LOG.debug('No python c extention for user program') self.ready = True