Created
January 22, 2020 20:46
-
-
Save tianrluo/69f5613d270c7286cdeb51e33ed16dda to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# inspired by gist.github.com/f0k/63a664160d016a491b2cbea15913d549 | |
from setuptools import setup, find_packages | |
import ctypes | |
def cuda_is_available(): | |
libnames = ('libcuda.so', 'libcuda.dylib', 'cuda.dll') | |
for name in libnames: | |
try: | |
ctypes.CDLL(name) | |
except OSError: | |
continue | |
else: | |
return True | |
else: | |
return False | |
return False | |
""" | |
it seems github dependency checker only cares about the initial | |
definition of the `REQUIRED_PACKAGES` variable. Hence appending | |
`cupy` at the initialization, pop it when `cuda` is missing. | |
""" | |
REQUIRED_PACKAGES = ['torch>=1.3', 'numpy', 'cupy>=7.0.0'] | |
if not cuda_is_available(): | |
REQUIRED_PACKAGES.remove('cupy>=7.0.0') |
isn't
torch.cuda.is_available()
more convenient?
At CI install time, torch
is often not available yet.
actually, you can add pip install torch
before python setup.py install
in your CI config file.
@speedcell4
Ah... wasn't aware of that...
Then I guess the only benefit of the configs here is that ctypes
comes w/ python.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
isn't
torch.cuda.is_available()
more convenient?