Changeset 8b31efa in sasmodels
- Timestamp:
- Oct 15, 2018 1:27:14 PM (6 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 508475a, d5ce7fa
- Parents:
- 4de14584
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/guide/gpu_setup.rst
r63602b1 r8b31efa 94 94 Device Selection 95 95 ================ 96 **OpenCL drivers** 97 96 98 If you have multiple GPU devices you can tell the program which device to use. 97 99 By default, the program looks for one GPU and one CPU device from available … … 104 106 was used to run the model. 105 107 106 **If you don't want to use OpenCL, you can set** *SAS_OPENCL=None* 107 **in your environment settings, and it will only use normal programs.** 108 109 If you want to use one of the other devices, you can run the following 108 If you want to use a specific driver and devices, you can run the following 110 109 from the python console:: 111 110 … … 115 114 This will provide a menu of different OpenCL drivers available. 116 115 When one is selected, it will say "set PYOPENCL_CTX=..." 117 Use that value as the value of *SAS_OPENCL*. 116 Use that value as the value of *SAS_OPENCL=driver:device*. 117 118 To use the default OpenCL device (rather than CUDA or None), 119 set *SAS_OPENCL=opencl*. 120 121 In batch queues, you may need to set *XDG_CACHE_HOME=~/.cache* 122 (Linux only) to a different directory, depending on how the filesystem 123 is configured. You should also set *SAS_DLL_PATH* for CPU-only modules. 124 125 -DSAS_MODELPATH=path sets directory containing custom models 126 -DSAS_OPENCL=vendor:device|cuda:device|none sets the target GPU device 127 -DXDG_CACHE_HOME=~/.cache sets the pyopencl cache root (linux only) 128 -DSAS_COMPILER=tinycc|msvc|mingw|unix sets the DLL compiler 129 -DSAS_OPENMP=1 turns on OpenMP for the DLLs 130 -DSAS_DLL_PATH=path sets the path to the compiled modules 131 132 133 **CUDA drivers** 134 135 If OpenCL drivers are not available on your system, but NVidia CUDA 136 drivers are available, then set *SAS_OPENCL=cuda* or 137 *SAS_OPENCL=cuda:n* for a particular device number *n*. If no device 138 number is specified, then the CUDA drivers looks for look for 139 *CUDA_DEVICE=n* or a file ~/.cuda-device containing n for the device number. 140 141 In batch queues, the SLURM command *sbatch --gres=gpu:1 ...* will set 142 *CUDA_VISIBLE_DEVICES=n*, which ought to set the correct device 143 number for *SAS_OPENCL=cuda*. If not, then set 144 *CUDA_DEVICE=$CUDA_VISIBLE_DEVICES* within the batch script. You may 145 need to set the CUDA cache directory to a folder accessible across the 146 cluster with *PYCUDA_CACHE_DIR* (or *PYCUDA_DISABLE_CACHE* to disable 147 caching), and you may need to set environment specific compiler flags 148 with *PYCUDA_DEFAULT_NVCC_FLAGS*. You should also set *SAS_DLL_PATH* 149 for CPU-only modules. 150 151 **No GPU support** 152 153 If you don't want to use OpenCL or CUDA, you can set *SAS_OPENCL=None* 154 in your environment settings, and it will only use normal programs. 155 156 In batch queues, you may need to set *SAS_DLL_PATH* to a directory 157 accessible on the compute node. 158 118 159 119 160 Device Testing … … 154 195 *Document History* 155 196 156 | 201 7-09-27Paul Kienzle197 | 2018-10-15 Paul Kienzle -
sasmodels/kernelcl.py
rb0de252 r8b31efa 227 227 self.context = None 228 228 if 'SAS_OPENCL' in os.environ: 229 #Setting PYOPENCL_CTX as a SAS_OPENCL to create cl context 230 os.environ["PYOPENCL_CTX"] = os.environ["SAS_OPENCL"] 229 # Set the PyOpenCL environment variable PYOPENCL_CTX 230 # from SAS_OPENCL=driver:device. Ignore the generic 231 # SAS_OPENCL=opencl, which is used to select the default 232 # OpenCL device. Don't need to check for "none" or 233 # "cuda" since use_opencl() would return False if they 234 # were defined, and we wouldn't get here. 235 dev_str = os.environ["SAS_OPENCL"] 236 if dev_str and dev_str.lower() != "opencl": 237 os.environ["PYOPENCL_CTX"] = dev_str 238 231 239 if 'PYOPENCL_CTX' in os.environ: 232 240 self._create_some_context() … … 568 576 current_time = time.clock() 569 577 if current_time - last_nap > 0.5: 570 time.sleep(0.0 5)578 time.sleep(0.001) 571 579 last_nap = current_time 572 580 cl.enqueue_copy(self.queue, self.result, self.result_b) -
sasmodels/kernelcuda.py
r74e9b5f r8b31efa 444 444 self.q_input = q_input # allocated by GpuInput above 445 445 446 self._need_release = [self.result_b , self.q_input]446 self._need_release = [self.result_b] 447 447 self.real = (np.float32 if dtype == generate.F32 448 448 else np.float64 if dtype == generate.F64 … … 467 467 # Call kernel and retrieve results 468 468 last_nap = time.clock() 469 step = 1000000 //self.q_input.nq + 1469 step = 100000000//self.q_input.nq + 1 470 470 #step = 1000000000 471 471 for start in range(0, call_details.num_eval, step): … … 479 479 current_time = time.clock() 480 480 if current_time - last_nap > 0.5: 481 time.sleep(0.0 5)481 time.sleep(0.001) 482 482 last_nap = current_time 483 483 sync() … … 500 500 Release resources associated with the kernel. 501 501 """ 502 if self.result_b is not None:503 self.result_b.free()504 self.result_b = None502 for p in self._need_release: 503 p.free() 504 self._need_release = [] 505 505 506 506 def __del__(self):
Note: See TracChangeset
for help on using the changeset viewer.