pycuda fail; Theano with Anaconda - python

I'm using Anaconda to install Theano on MacOSX (Mavericks 10.9 ), just like this post explains: "How to make Theano operate on Mac Lion?"
theano.test()
This command gives the same error as in the post above. It gives that error on an Ubuntu 14.1, System 76 as well.
I am able to import commands from Theano; but I still would like to understand why theano.test() fails. The packages CUDA and Boost were already installed before running...
(Reference: See section: "Testing your Installation" http://deeplearning.net/software/theano/install.html)
As the post suggests, I assumed the fix would come from installing the XCode command line, homebrew, and pycuda. The first two were installed just fine. But pycuda fails:
pip install pycuda
....gives the following error:
> src/cpp/cuda.cpp -o build/temp.macosx-10.5-x86_64-3.4/src/cpp/cuda.o
> In file included from src/cpp/cuda.cpp:1:
>
> src/cpp/cuda.hpp:14:10: fatal error: 'cuda.h' file not found
> #include <cuda.h>
> ^
> 1 error generated.
> error: command 'gcc' failed with exit status 1
>
> Command "//anaconda/bin/python3 -c "import setuptools,
>tokenize;__file__='/private/var/folders/5b/5g1stsns34x_7mgynxhhvf1h0000gn/T/pip-build-4raihcb4/pycuda/setup.py';exec(compile(getattr(tokenize,
> 'open', open)(__file__).read().replace('\r\n', '\n'), __file__,
> 'exec'))" install --record
> /var/folders/5b/5g1stsns34x_7mgynxhhvf1h0000gn/T/pip-kr_3ws22-record/install-record.txt
>> --single-version-externally-managed --compile" failed with error code 1 in
> /private/var/folders/5b/5g1stsns34x_7mgynxhhvf1h0000gn/T/pip-build-4raihcb4/pycuda
It seems like the first error (gcc failed) is that the complier is not finding gcc. (Note again: I installed the MacOSX command line tools)
I run
which gcc
this gives usr/bin/gcc
I also tried :
python configure.py --cuda-root=/usr/local/cuda
--cuda-inc-dir=/Developer/NVIDIA/CUDA-5.5/include --cudart-lib-dir=/Developer/NVIDIA/CUDA-5.5/lib
That didn't work as well.
Has anyone else had this difficulty installing pycuda and can make a recommendation here? Thanks.

The first error is not indicating that gcc failed to be found, rather it is saying that gcc reported an error and that error was that the file cuda.h could not be found.
That error suggests you don't have the CUDA toolkit installed. You need to install this before proceeding to install PyCUDA. The CUDA toolkit can be downloaded from NVIDIA's website.
The PyCUDA web page indicates that it has the following prerequisites: BOOST, CUDA, and Numpy.

I resolved this same issue with a combination of two things:
Making sure nvcc is in your PATH seems resolve the compilation errors. If you then encounter the following linking error:
ld: file not found: #rpath/CUDA.framework/Versions/A/CUDA for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I fixed it changing the #rpath reference in libcuda.dylib to an absolute path:
install_name_tool -change #rpath/CUDA.framework/Versions/A/CUDA \ /Library/Frameworks/CUDA.framework/CUDA \
/usr/local/cuda/lib/libcuda.dylib

Related

llvmlite failed to install. Error building llvmlite

I have a problem with installing llvmlite, which is need for installing Numba.
I searched for answers to my problem, but nothing is working.
The command I used to install numba and llvmlite:
pip install numba
pip install llvmlite
enter code here
Error code:
ERROR: Failed building wheel for llvmlite
Running setup.py clean for llvmlite
Failed to build llvmlite
Installing collected packages: llvmlite
Running setup.py install for llvmlite ... error
ERROR: Command errored out with exit status 1:
command: 'c:\python39\python.exe' -u -c 'import sys, setuptools, tokenize;
sys.argv[0] = '"'"'C:\\Users\\owner\\AppData\\Local\\Temp\\pip-install-hif24z13\
\llvmlite_0e0be86c2ed14239b3eec11a3bd23922\\setup.py'"'"'; __file__='"'"'C:\\Use
rs\\owner\\AppData\\Local\\Temp\\pip-install-hif24z13\\llvmlite_0e0be86c2ed14239
b3eec11a3bd23922\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file
__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(c
ode, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\owner\AppData\Local\
Temp\pip-record-sipsgexo\install-record.txt' --single-version-externally-managed
--compile --install-headers 'c:\python39\Include\llvmlite'
cwd: C:\Users\owner\AppData\Local\Temp\pip-install-hif24z13\llvmlite_0e
0be86c2ed14239b3eec11a3bd23922\
Complete output (59 lines):
running install
running build
got version from file C:\Users\owner\AppData\Local\Temp\pip-install-hif24z13
\llvmlite_0e0be86c2ed14239b3eec11a3bd23922\llvmlite/_version.py {'version': '0.3
5.0', 'full': 'ea23b026930cc00824c907172383f54c9d438e6b'}
running build_ext
c:\python39\python.exe C:\Users\owner\AppData\Local\Temp\pip-install-hif24z1
3\llvmlite_0e0be86c2ed14239b3eec11a3bd23922\ffi\build.py
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 6.3.9600.
-- The C compiler identification is MSVC 19.16.27043.0
-- The CXX compiler identification is MSVC 19.16.27043.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Stu
dio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual S
tudio/2017/BuildTools/VC/Tools/MSVC/14.16.27023/bin/Hostx86/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/owner/AppData/Local/Temp/tmp1e
4ama0u
CMake Deprecation Warning at CMakeLists.txt:2 (cmake_minimum_required):
Compatibility with CMake < 2.8.12 will be removed from a future version of
CMake.
Update the VERSION argument <min> value or use a ...<max> suffix to tell
CMake that the project does not need compatibility with older versions.
-- Selecting Windows SDK version 10.0.18362.0 to target Windows 6.3.9600.
CMake Error at CMakeLists.txt:9 (find_package):
Could not find a package configuration file provided by "LLVM" with any of
the following names:
LLVMConfig.cmake
llvm-config.cmake
Add the installation prefix of "LLVM" to CMAKE_PREFIX_PATH or set
"LLVM_DIR" to a directory containing one of the above files. If "LLVM"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
See also "C:/Users/owner/AppData/Local/Temp/pip-install-hif24z13/llvmlite_0e
0be86c2ed14239b3eec11a3bd23922/ffi/build/CMakeFiles/CMakeOutput.log".
Trying generator 'Visual Studio 15 2017 Win64'
Traceback (most recent call last):
File "C:\Users\owner\AppData\Local\Temp\pip-install-hif24z13\llvmlite_0e0b
e86c2ed14239b3eec11a3bd23922\ffi\build.py", line 191, in <module>
main()
File "C:\Users\owner\AppData\Local\Temp\pip-install-hif24z13\llvmlite_0e0b
e86c2ed14239b3eec11a3bd23922\ffi\build.py", line 179, in main
main_win32()
File "C:\Users\owner\AppData\Local\Temp\pip-install-hif24z13\llvmlite_0e0b
e86c2ed14239b3eec11a3bd23922\ffi\build.py", line 93, in main_win32
try_cmake(here_dir, build_dir, generator)
File "C:\Users\owner\AppData\Local\Temp\pip-install-hif24z13\llvmlite_0e0b
e86c2ed14239b3eec11a3bd23922\ffi\build.py", line 28, in try_cmake
subprocess.check_call(['cmake', '-G', generator, cmake_dir])
File "c:\python39\lib\subprocess.py", line 373, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '-G', 'Visual Studio 15 20
17 Win64', 'C:\\Users\\owner\\AppData\\Local\\Temp\\pip-install-hif24z13\\llvmli
te_0e0be86c2ed14239b3eec11a3bd23922\\ffi']' returned non-zero exit status 1.
error: command 'c:\\python39\\python.exe' failed with exit code 1
----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\python39\python.exe' -u -c 'i
mport sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\owner\\AppData\\L
ocal\\Temp\\pip-install-hif24z13\\llvmlite_0e0be86c2ed14239b3eec11a3bd23922\\set
up.py'"'"'; __file__='"'"'C:\\Users\\owner\\AppData\\Local\\Temp\\pip-install-hi
f24z13\\llvmlite_0e0be86c2ed14239b3eec11a3bd23922\\setup.py'"'"';f=getattr(token
ize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'
\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --reco
rd 'C:\Users\owner\AppData\Local\Temp\pip-record-sipsgexo\install-record.txt' --
single-version-externally-managed --compile --install-headers 'c:\python39\Inclu
de\llvmlite' Check the logs for full command output.
Please help me, I have been looking for a way to solve this problem for 2 days, but without success, I am desperate
Go to here and download llvmlite package for your python version, e.g. llvmlite‑0.35.0‑cp39‑cp39‑win_amd64.whl for Python 3.9.
Then install pip install llvmlite‑0.35.0‑cp39‑cp39‑win_amd64.whl.
Probably llvmlite is not yet officially supported on Python 3.9. That's why there are only unofficial builds like on this site.
Also if you need numba then go to here and download/install numba‑0.51.2‑cp39‑cp39‑win_amd64.whl. Latest numba 0.52.0 is not yet compiled by this site owner for Python 3.9, only version 0.51.2.
Also when installing numba you may need to pass key --no-deps to pip to ignore installing dependencies, like pip install --no-deps numba‑0.51.2‑cp39‑cp39‑win_amd64.whl because numba 0.51.2 wants a bit older version of llvmlite by default. Also few small extra dependencies are needed to be installed manually. So all steps for installing on Win Python 3.9 64-bit are:
pip install llvmlite‑0.35.0‑cp39‑cp39‑win_amd64.whl (.whl file from here).
pip install --no-deps numba‑0.51.2‑cp39‑cp39‑win_amd64.whl (.whl file from here).
pip install numpy importlib-metadata (small few extra dependencies via regular pip install without downloading).
PS. Site by link mentioned above has only Windows packages. Also this site has many other popular wheels packages for Python, most of them are placed on this site because they are not currently available inside official PIP repository..
Install llvm {version} greater than 7 using command
suda apt install llvm-{version}
Than to install numba or llvmlite {package} use command
LLVM_CONFIG={path to llvm-config file} pip install {package}
For example (For llvm version=8)
LLVM_CONFIG=/usr/bin/llvm-config-8 pip install numba==0.48
llvmlite does not have support for python 3.9 yet. Uninstall python 3.9 and download python 3.8.7 and try again. This solved for the problem for me.
Another approach is to install llvmlite version which is directly compatible with Python 3.9.
today I successfully did that with pip install llvmlite==0.36.0rc1; you may want to use some other latest version.

how to install spacy for python 3.4, windows 7?

I am trying to install the spacy python library for python 3.4 on windows 7. i keep getting install errors (the important-looking error messages are below).
I installed it for 2.7, but I can't seem to install it for 3.4.
I tried doing:
pip3.4 install -U spacy
But it does not seem to work. Does anybody have any ideas? I'm trying to avoid crazy system surgery. There must be some simple way to do this.
Warning: The nvcc binary could not be located in your $PATH. For GPU capability, either add it to your path, or set $CUDA_HOME
warning: no files found matching '*.cpp' under directory 'include'
warning: no files found matching 'buildbot.json'
***********************************************************
WARNING: One of the following dependencies is unresolved:
ctypes >=1.0.1
readline >=1.7.1
***********************************************************
error: Unable to find vcvarsall.bat
Cleaning up...
Command C:\Python34\python.exe -c "import setuptools, tokenize;file='C:\Users\joe\AppData\Local\Temp\pip_build_joe\spacy\setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record C:\Users\joe\AppData\Local\Temp\pip-sxqy1vof-record\install-record.txt --single-version-externally-managed --compile failed with error code 1 in C:\Users\joe\AppData\Local\Temp\pip_build_joe\spacy
Storing debug log for failure in C:\Users\joe\pip\pip.log
In order for python to detect it you must place it in the following directory.
C:\Python27\
or where ever python is located.

Install caffe/pycaffe on MacOSX High Sierra

I'm following this tutorial to install caffe on my OSX High Sierra.
I followed all steps but I'm stucked when installing R-CNN example at this step:
$ make -j8 && make pycaffe
LD -o .build_release/lib/libcaffe.so
clang: warning: argument unused during compilation: '-pthread' [-Wunused-command-line-argument]
ld: cannot link directly with /System/Library/Frameworks//vecLib.framework/vecLib for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [.build_release/lib/libcaffe.so] Error 1
But the library veclib is present:
$ ls /System/Library/Frameworks//vecLib.framework/vecLib
/System/Library/Frameworks//vecLib.framework/vecLib
Can you help me please to solve this issue ?
I met the same issue. I installed Xcode 9.3 Commandline tool and changed cmake/Modules/FindvecLib.cmake to something like this and it works:
find_path(vecLib_INCLUDE_DIR cblas.h
DOC "vecLib include directory"
PATHS /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Headers/
NO_DEFAULT_PATH)
For my case, NO_DEFAULT_PATH must be set or there will be still link error.
You can also refer to this.

error: command 'gcc' failed with exit status 1 installing Fatiando (Python Package)

I am trying to install fatiando, a geophysical modelling package for Python.
I have a Mac with OS X v10.9.5. I am getting all the dependencies for Fatiando (via Anaconda) by following the recommended installation suggested on the package site. I have Xcode installed.
I get a list of warnings and a final error message:
fatiando/gravmag/_polyprism.c:349:10: fatal error: 'omp.h' file not found
#include "omp.h"
^
1 warning and 1 error generated.
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "//anaconda/bin/python -c "import setuptools, tokenize;__file__='/var/folders/32/mwq0jhwd3dx7vjqmm8hkljp80000gn/T/pip-QFjo6d-build/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/32/mwq0jhwd3dx7vjqmm8hkljp80000gn/T/pip-CY4vyX-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /var/folders/32/mwq0jhwd3dx7vjqmm8hkljp80000gn/T/pip-QFjo6d-build
Macintosh-5:fatiando matteoniccoli$
The full Terminal output (1100+ lines) can be found here.
I already contacted the developers, this does not seem to be a Fatiando issue.
Any suggestions?
UPDATE, March 15
When I first posted this I did not have Xcode, then I downloaded the latest Xcode from Apple store. Tried again, got the same message. Then I read this and downloaded gcc from here, and installed directly. When I type on terminal: gcc --version, I get this: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
After that, though, I still get similar messages. Following another stackoverflow lead, I tried to install setuptools from here
using curl https://bootstrap.pypa.io/ez_setup.py -o - | python
Now I get a different error (at the end again of a long output) when I try to install fatiando:
fatiando/gravmag/_polyprism.c:349:10: fatal error: 'omp.h' file not found
#include "omp.h"
^
1 warning and 1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
----------------------------------------
Command "//anaconda/bin/python -c "import setuptools, tokenize;__file__='/private/var/folders/32/mwq0jhwd3dx7vjqmm8hkljp80000gn/T/pip-build-m1ieVO/fatiando/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/32/mwq0jhwd3dx7vjqmm8hkljp80000gn/T/pip-9wI6Z7-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /private/var/folders/32/mwq0jhwd3dx7vjqmm8hkljp80000gn/T/pip-build-m1ieVO/fatiando
Someone from a forum asked me by email:
Re Fatiando, did you install Xcode command line tools? Eg see this
http://railsapps.github.io/xcode-command-line-tools.html
But when I try to verify tI’ve successfully installed Xcode Command Line Tools as suggested there, I get this, so I assume it was not the issue:
-bash: /Library/Developer/CommandLineTools: is a directory
UPDATE MARCH 16
Tried solution suggested by Leo Uieda.
pip install --upgrade https://github.com/fatiando/fatiando/archive/kill-omp.zip went without a problem, but
pip install --upgrade https://github.com/fatiando/fatiando/archive/master.zip gets me back at square 1:
...
...
fatiando/gravmag/_polyprism.c:349:10: fatal error: 'omp.h' file not found
#include "omp.h"
^
1 warning and 1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
----------------------------------------
Rolling back uninstall of fatiando
This is a very common problem with the Fatiando install, specially on Windows and Mac. OpenMP was introduced in PR 106 for the fatiando.gravmag forward modeling modules. It was easy to implement (just replace a range(ndata) with a prange(ndata)) and was resulting in 1.5-2x speedup over sequential execution. Also, the parallel execution was automatic. So it seemed like a good trade-off at the time ("Just install an extra dependency? What could go wrong?").
The problems began when the Anaconda gcc and the default Mac gcc didn't come with OpenMP. So Windows users had to install an extra dependency (in a very specific order, like a satanic ritual) and Mac users had to fend for themselves.
OpenMP and compiled Cython modules are being removed from Fatiando (#169) in preference of multiprocessing and numba. This would make it a pure Python package (no compilation necessary) and most of the install issues should be resolved.
In the mean time, PR 177 removes the OpenMP requirement from the Cython modules. This should fix your current install problems. To get the changes right away, you can install the version from the kill-omp branch by running:
pip install --upgrade https://github.com/fatiando/fatiando/archive/kill-omp.zip
If the above command doesn't work, it means that the pull request has been merged into the main branch of the project (master). If that's the case, you can install the latest version from the master branch:
pip install --upgrade https://github.com/fatiando/fatiando/archive/master.zip
These changes will be included in the future v0.4 release. Hope this fixes your problem.
(It would be useful to know which version of gcc you are using.)
gcc did not ship with OpenMP prior to v4.9.
See this answer could help you update gcc it using xcode.

Error when Installing Pycurl on OS X

I am trying to install pycurl on OS X Mavericks. I have downloaded and installed the Xcode dev tools to have some compiler. I went into the Xcode preferences and made sure that I have downloaded all the compliers I would need but still getting this error
When I try to install pycurl I get the following errors. Any help would be much appreciated.
local-mbp:~ $ sudo easy_install pycurl
Password:
Searching for pycurl
Reading http://pypi.python.org/simple/pycurl/
Best match: pycurl 7.19.3.1
Downloading https://pypi.python.org/packages/source/p/pycurl/pycurl-7.19.3.1.tar.gz#md5=6df8fa7fe8b680d93248da1f8d4fcd12
Processing pycurl-7.19.3.1.tar.gz
Running pycurl-7.19.3.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-jKMmtE/pycurl-7.19.3.1/egg-dist-tmp-9z89Ns
Using curl-config (libcurl 7.30.0)
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
error: Setup script exited with error: command 'cc' failed with exit status 1
local-mbp:~ $ which gcc
/usr/bin/gcc
local-mbp:~$ which cc
/usr/bin/cc
local-mbp:~$
Try this:
brew install python
Double check you are using brewed Python:
which python
(Should return something like /usr/local/bin/python)
Install pycurl with pip.
pip install pycurl
I just tested this on Mavericks.
Try specify the ARCHFLAGS env var:
ARCHFLAGS="-arch x86_64" pip install pycurl

Categories