Skip to content

Commit

Permalink
add cupy (with right version) as dependency if needed
Browse files Browse the repository at this point in the history
This is part of ongoing effort addressing #18
  • Loading branch information
leofang committed May 10, 2019
1 parent e725322 commit 80853c7
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,20 @@

# for generating .cubin files
# TODO: add a flag to do this only if GPU support is needed?
from nsls2ptycho.core.ptycho.build_cuda_source import compile
cubin_path = compile()
import nsls2ptycho.core.ptycho.build_cuda_source as bcs
cubin_path = bcs.compile()

# if GPU support is needed, check if cupy exists
if len(cubin_path) > 0:
cuda_ver = str(bcs._cuda_version)
major = str(int(cuda_ver[:-2])//10)
minor = str(int(cuda_ver[-2:])//10)
try:
import cupy
except ImportError:
cupy_ver = 'cupy-cuda'+major+minor
print("CuPy not found. Will install", cupy_ver+"...", file=sys.stderr)
REQUIREMENTS.append(cupy_ver+'>=6.0.0b3') # for experimental FFT plan feature

setup(name=NAME,
version=VERSION,
Expand All @@ -45,7 +57,7 @@
'console_scripts': ['run-ptycho-backend = nsls2ptycho.core.ptycho.recon_ptycho_gui:main']
},
install_requires=REQUIREMENTS,
extras_require={'GPU': 'cupy'}, # this will build cupy from source, may not be the best practice!
#extras_require={'GPU': 'cupy'}, # this will build cupy from source, may not be the best practice!
ext_modules=cythonize("nsls2ptycho/core/ptycho/*.pyx"),
include_dirs=[numpy.get_include()],
#dependency_links=['git+https://github.com/leofang/ptycho.git#optimization']
Expand Down

0 comments on commit 80853c7

Please sign in to comment.