0

I am trying to install the python package pycuda on a Mac OS Mojave with python 3.8.1 using pip. I write:

python -m pip install pycuda

but after many trials I always end with the same error:

error: command 'clang' failed with exit status 1

I made: export CC=/usr/bin/clang export CXX=/usr/bin/clang++ in my .profile file but this did not helped.

The last part of the text written on the terminal says:

90 warnings generated.
clang -bundle -undefined dynamic_lookup -L/opt/local/lib -Wl,-headerpad_max_install_names -Wl,-syslibroot,/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk build/temp.macosx-10.14-x86_64-3.8/src/cpp/cuda.o build/temp.macosx-10.14-x86_64-3.8/src/cpp/bitlog.o build/temp.macosx-10.14-x86_64-3.8/src/wrapper/wrap_cudadrv.o build/temp.macosx-10.14-x86_64-3.8/src/wrapper/mempool.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/converter/builtin_converters.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/converter/type_id.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/converter/from_python.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/converter/registry.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/converter/arg_to_python_base.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/object/life_support.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/object/iterator.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/object/stl_iterator.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/object/function_doc_signature.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/object/pickle_support.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/object/function.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/object/enum.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/object/class.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/object/inheritance.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/wrapper.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/object_protocol.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/long.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/module.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/slice.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/dict.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/exec.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/numeric.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/object_operators.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/tuple.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/list.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/errors.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/str.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/python/src/import.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/smart_ptr/src/sp_collector.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/smart_ptr/src/sp_debug_hooks.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/system/src/error_code.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/thread/src/pthread/thread.o build/temp.macosx-10.14-x86_64-3.8/bpl-subset/bpl_subset/libs/thread/src/pthread/once.o build/temp.macosx-10.14-x86_64-3.8/src/wrapper/wrap_curand.o -L/Developer/NVIDIA/CUDA-10.2/lib -L/Developer/NVIDIA/CUDA-10.2/lib -L/Developer/NVIDIA/CUDA-10.2/lib/stubs -L/Developer/NVIDIA/CUDA-10.2/lib/stubs -L/usr/local/cuda/lib -L/Developer/NVIDIA/CUDA-10.2/lib -L/Developer/NVIDIA/CUDA-10.2/lib -L/Developer/NVIDIA/CUDA-10.2/lib/stubs -L/Developer/NVIDIA/CUDA-10.2/lib/stubs -L/usr/local/cuda/lib -lcuda -lcurand -o build/lib.macosx-10.14-x86_64-3.8/pycuda/_driver.cpython-38-darwin.so -Xlinker -rpath -Xlinker /Developer/NVIDIA/CUDA-10.2/lib -Xlinker -rpath -Xlinker /Developer/NVIDIA/CUDA-10.2/lib -Xlinker -rpath -Xlinker /Developer/NVIDIA/CUDA-10.2/lib/stubs -Xlinker -rpath -Xlinker /Developer/NVIDIA/CUDA-10.2/lib/stubs -Xlinker -rpath -Xlinker /usr/local/cuda/lib
ld: library not found for -lcuda
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang' failed with exit status 1
----------------------------------------

ERROR: Command errored out with exit status 1: /opt/local/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/p8/mxnrzwqj51z51zx_qql90bvr0000gn/T/pip-install-dkd5hqzy/pycuda/setup.py'"'"'; file='"'"'/private/var/folders/p8/mxnrzwqj51z51zx_qql90bvr0000gn/T/pip-install-dkd5hqzy/pycuda/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(file);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, file, '"'"'exec'"'"'))' install --record /private/var/folders/p8/mxnrzwqj51z51zx_qql90bvr0000gn/T/pip-record-efvcjkkh/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /Users/marce/Library/Python/3.8/include/python3.8/pycuda Check the logs for full command output.

obamakoak
  • 23
  • 5

1 Answers1

0

This is the actual error:

ld: library not found for -lcuda

The compiler cannot find your CUDA C library. You will have to install it first, and / or make sure that it's in a location where the compiler can find it.

See also this question on how to install CUDA on OSX.

If you use conda, you can also do

$ conda install cudatoolkit

to install a version of the CUDA toolkit.

Dion
  • 1,492
  • 11
  • 14
  • Thanks Dion. Still I get the error. I installed CUDA from their webpage (https://developer.nvidia.com), added to my .profile the lines "export PATH=/Developer/NVIDIA/CUDA-10.2/bin${PATH:+:${PATH}}" and "export DYLD_LIBRARY_PATH=/Developer/NVIDIA/CUDA-10.2/lib${DYLD_LIBRARY_PATH:+:${DYLD_LIBRARY_PATH}}", even I disabled the SIP, which apparently is needed to recognize the variable DYLD_LIBRARY_PATH. After doing this I tried again "python -m pip install pycuda" but I got the same error. I do not know how to make the compiler to find the CUDA C library. – obamakoak Apr 15 '20 at 19:05
  • I got it. It was necessary to install CUDA driver from https://www.nvidia.com/es-es/drivers/cuda/mac-driver-archive/. However now my problem is that when I run "import pycuda.autoinit" in a python script I get an error "pycuda._driver.LogicError: cuInit failed:". I checked the web and tried several options but I still have this problem. – obamakoak Apr 16 '20 at 00:07
  • Well... are your sure your Mac has an NVidia GPU? – Dion Apr 16 '20 at 07:52
  • I am not sure. How can I know? I read various threads about Apple not supporting NVIDIA CUDA for Mojave and later. I do not know if this means that it is not possible to use CUDA on Mac OS X Mojave or later. – obamakoak Apr 16 '20 at 11:44
  • Does your computer have an NVidia graphics card? What kind of Mac are you using? – Dion Apr 16 '20 at 11:46
  • My Mac is a MacBook Pro (13 inches, 2019) with a graphics card Intel Iris Plus Graphics 655, type GPU, bus integrated, VRAM (dynamic, máx.): 1536 MB, manufacturer: Intel, ID of the devide: 0x3ea5, ID of the revision: 0x0001, metal: compatible, family of functions macOS GPUFamily2 1 – obamakoak Apr 16 '20 at 17:03
  • So, the answer is no. You cannot use CUDA without a dedicated graphics card. – Dion Apr 16 '20 at 17:10
  • Ops. So bad! I thought is was not mandatory to have a NVIDIA graphics card to use CUDA. Thanks for the help. At least I arrived to a conclusion before getting crazy. – obamakoak Apr 16 '20 at 19:00
  • It seems like your original problem was solved. If so, please consider accepting this answer. – Dion Apr 16 '20 at 19:55