File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -261,7 +261,9 @@ Free Energy Perturbation (FEP) with GCMC using `loch` is supported via the
261261
262262## Notes
263263
264- * Make sure that ` nvcc ` is in your ` PATH ` .
264+ * Make sure that ` nvcc ` is in your ` PATH ` . If you require a different ` nvcc ` to that
265+ provided by conda, you can set the ` PYCUDA_NVCC ` environment variable to point
266+ to the desired ` nvcc ` binary, or use the ` nvcc ` kwarg in the ` GCMCSampler ` constructor.
265267
266268* A future version supporting AMD GPUs via PyOpenCL is planned.
267269
Original file line number Diff line number Diff line change @@ -77,6 +77,7 @@ def __init__(
7777 log_file = "gcmc.txt" ,
7878 log_level = "error" ,
7979 seed = None ,
80+ nvcc = None ,
8081 ** kwargs ,
8182 ):
8283 """
@@ -206,6 +207,10 @@ def __init__(
206207
207208 seed: int
208209 The seed for the random number generator.
210+
211+ nvcc: str
212+ The path to the nvcc compiler. If None, the default nvcc
213+ in the PATH will be used.
209214 """
210215
211216 # Validate the input.
@@ -371,6 +376,16 @@ def __init__(
371376 # Create a random number generator.
372377 self ._rng = _np .random .default_rng (self ._seed )
373378
379+ if nvcc is not None :
380+ if not isinstance (nvcc , str ):
381+ raise ValueError ("'nvcc' must be of type 'str'" )
382+ if not _os .path .exists (nvcc ):
383+ raise ValueError (f"'nvcc' does not exist: { nvcc } " )
384+ else :
385+ from shutil import which
386+
387+ nvcc = _os .environ .get ("PYCUDA_NVCC" , which ("nvcc" ))
388+
374389 from pycuda .tools import make_default_context
375390
376391 # Set the CUDA device.
@@ -511,6 +526,7 @@ def __init__(
511526 "NUM_ATOMS" : self ._num_atoms ,
512527 },
513528 no_extern_c = True ,
529+ nvcc = nvcc ,
514530 )
515531 self ._kernels ["cell" ] = mod .get_function ("setCellMatrix" )
516532 self ._kernels ["rng" ] = mod .get_function ("initialiseRNG" )
You can’t perform that action at this time.
0 commit comments