Installing Numba on a Cluster (Compute Canada) using virtualenv - python

I am trying to install Numba on a cluster so I can run my Jitted python codes on there. However I keep running into an error with "libllvmlite.so" when I try to import Numba. This is done on the Cedar cluster using virtualenv. Numba is installed using pip (and also tried pip3).
I start off my activating my enviroment using (... is the directory to my enviroment folder) :
source ~/.../ENV/bin/activate.
Then I use pip to install Numba (I've also tried used pip uninstall to remove and reinstall Numba).
However when I load up Python 3.7.0 on my enviroment, I obtain an error whenever I try to import Numba.
I use pip show to check versions: Python 3.7.0, Numba 0.53.1, llvmlite 0.36.0.
Here is the output of my terminal:
(ENV) [04:12:46] patrick7#cedar1 > [~/projects/def-mann/patrick7/diffusioncluster]python
Python 3.7.0 (default, Sep 25 2018, 18:19:16)
[GCC 5.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numba
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/patrick7/projects/def-mann/patrick7/diffusioncluster/ENV/lib/python3.7/site-packages/numba/__init__.py", line 19, in <module>
from numba.core import config
File "/home/patrick7/projects/def-mann/patrick7/diffusioncluster/ENV/lib/python3.7/site-packages/numba/core/config.py", line 16, in <module>
import llvmlite.binding as ll
File "/home/patrick7/projects/def-mann/patrick7/diffusioncluster/ENV/lib/python3.7/site-packages/llvmlite/binding/__init__.py", line 4, in <module>
from .dylib import *
File "/home/patrick7/projects/def-mann/patrick7/diffusioncluster/ENV/lib/python3.7/site-packages/llvmlite/binding/dylib.py", line 3, in <module>
from llvmlite.binding import ffi
File "/home/patrick7/projects/def-mann/patrick7/diffusioncluster/ENV/lib/python3.7/site-packages/llvmlite/binding/ffi.py", line 191, in <module>
raise OSError("Could not load shared object file: {}".format(_lib_name))
OSError: Could not load shared object file: libllvmlite.so
I have tried other solutions found online (reinstall, try different versions...), so far none has worked. Any help would be greatly appreciated! Thanks!

I figured out the solution to my problem.
What I've tried and didn't work:
Install llvmlite using pip manually
Downgrade to Numba version 0.43 since its the oldest version compatible with Python 3.7
Uninstall (llvmlite numpy and numba) and reinstalling Numba (which automatically installs it's dependancies) after upgrading Pip to the latest version
What worked:
Upgrading Python from 3.7.0 to 3.7.10
It seems like for Python version >= 3.7.3, the default command pip install numba works flawlessly!
Thanks for reading!

Related

importing jax fails on mac with m1 chip

For python 3.8.8 and using the new mac air (with the m1 chip), in jupyter notebooks and in python terminal, import jax raises this error
Python 3.8.8 (default, Apr 13 2021, 12:59:45)
[Clang 10.0.0 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import jax
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/steve/Documents/code/jax/jax/__init__.py", line 37, in <module>
from . import config as _config_module
File "/Users/steve/Documents/code/jax/jax/config.py", line 18, in <module>
from jax._src.config import config
File "/Users/steve/Documents/code/jax/jax/_src/config.py", line 26, in <module>
from jax import lib
File "/Users/steve/Documents/code/jax/jax/lib/__init__.py", line 63, in <module>
cpu_feature_guard.check_cpu_features()
RuntimeError: This version of jaxlib was built using AVX instructions, which your CPU and/or operating system do not support. You may be able work around this issue by building jaxlib from source.
I suspect it occurs because of the m1 chip.
I tried using jax with pip install jax, then I built it from source as suggested by the comment, by cloning their repository and following the instructions given here, but the same error message shows.
Thanks #jakevdp I looked at the issue you linked and found a workaround :
Thanks to Noah who mentioned in issue #5501 that you could just use a previous version of jax and jaxlib, for my purposes jaxlib==0.1.60 and jax==0.2.10 work just fine!
JAX does not yet provide pre-built jaxlib wheels that are compatible with M1 chips. The best source of information I know on building jaxlib on M1 is probably this github issue: https://github.com/google/jax/issues/5501, which also tracks improving this support.
Hopefully M1 support will be improved in the near future, but it's taking a while for the scientific computing infrastructure up and down the stack to catch up with the requirements of the new chips.
I had a similar problem. Since I already had Anaconda installed and didn't want to clutter up my space with Anaconda + miniconda + homebrew versions of python and package management and whatever, I hunted around for a simple solution. What ended up working for me was first uninstalling jax and jaxlib and then installing jax and jaxlib via conda-forge directly:
pip uninstall jax jaxlib
conda install -c conda-forge jaxlib
conda install -c conda-forge jax
As of now (January 2022), jax is available for M1 Macs. Make sure to uninstall jax and jaxlib and then install the new packages via pip:
pip install --upgrade jax jaxlib
Afterwards, you can use jax without problems.
--Edit--
I am running on a machine with the following specs:
ProductName: macOS
ProductVersion: 12.1
BuildVersion: 21C52
and with Python 3.9.6 within a conda environment.

ImportError: libhdf5_serial.so.100: Installing opencv-contrib-python package on ARM CPU (Stratodesk OS)

I am trying to install opencv package on Raspberry Pi (Stratodesk OS). the best shot I got so far is through: https://www.piwheels.hostedpi.com/simple
However, after installing
pip install opencv-contrib-python --extra-index-url https://www.piwheels.hostedpi.com/simple
when importing the cv2 in python I get import error message related to libhdf5_serial.so.100:
root#PNAR55:~# python3
Python 3.5.2 (default, Nov 12 2018, 13:43:14)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
import cv2
Traceback (most recent call last):
File "", line 1, in
File "/usr/local/lib/python3.5/dist-packages/cv2/init.py", line 3,
in
from .cv2 import *
ImportError: libhdf5_serial.so.100: cannot open shared object file: No
such file or directory
besides, I tried to install opencv-python but without success
pip install opencv-python --extra-index-url https://www.piwheels.hostedpi.com/simple
when importing cv2, I am getting a different ImportError message related to liblapack.so.3
import cv2
Traceback (most recent call last): File "", line
1, in File
"/usr/local/lib/python3.5/dist-packages/cv2/init.py", line 3, in
from .cv2 import * ImportError: liblapack.so.3: cannot open shared object file: No such file or directory
for your information, Stratodesk OS is quite different that Raspbian. I do not have git, cmake, apt-get commands.
if there is a way to overcome the error messages I am getting
This problem is due to an incompatibility between your board and the OpenCV version. If you installed it via pip try pip uninstall opencv-python or pip3 uninstall opencv-python (depending of the python version you need (pip for python2 and pip for python3). After uninstaling is complete, try to search for an older version of opencv and install via pip3 install opencv-python==3.4.6.27 (this is the version that worked for me. I'm almost sure you'll need another one). Also, check this link, and this one!

Is it Possible to have Opencv installed for both Python 2 and Python 3 in Windows?

After installing Opencv for Python 3, I went on to try installing Opencv for python 2. I had a lot of trouble searching for the problem then after using dependency walker and downloading the missing dll, it worked. However IDLE for Python 3 gave me this message.
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import cv
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import cv
File "C:\Python37\lib\site-packages\cv.py", line 1, in <module>
from cv2.cv import *
File "C:\Python37\lib\site-packages\cv2\__init__.py", line 3, in <module>
from .cv2 import *
ImportError: DLL load failed: The specified module could not be found.
>>> import cv2
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import cv2
File "C:\Python37\lib\site-packages\cv2\__init__.py", line 3, in <module>
from .cv2 import *
ImportError: DLL load failed: The specified module could not be found.
>>>
Edit: I think I may have to downgrade my Python 3 version. I am still open to suggestions though!
According to the PyPi repository, opencv is available for many versions of Python from 2.7 to 3.7. So, yes you can install it twice for Python 2.7 and 3.7 (if it is available for your OS).
But you need to have two Python environments, a.k.a. Virtualenvs! Of course Conda can solve this problem but you can also use the virtualenv tools. Follow the instructions to install it. It is a requirement for Python 2.
Choose a directory to store your virtualenvs, for Instance ~/virtualenv in your HOME. Create it if necessary.
For Python 2.7, you can run:
cd ~/virtualenv
virtualenv -p /path/to/python2 py2-demo
source py2-demo/bin/activate
pip install opencv-python
For Python > 3.3, you can use the venv module:
cd ~/virtualenv
python3 -m venv py3-demo
source py3-demo/bin/activate
pip install opencv-python

Tensorflow on OSX: Failed to load the native TensorFlow runtime (No module named pywrap_tensorflow_internal)

I'm trying to install Tensorflow (r1.2) on my MacBook (OSX 10.12.5).
The installation works, but I'm getting errors, when I try to import TF in python.
Python 2.7.10 (default, Feb 7 2017, 00:08:15)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "tensorflow/__init__.py", line 24, in <module>
from tensorflow.python import *
File "tensorflow/python/__init__.py", line 49, in <module>
from tensorflow.python import pywrap_tensorflow
File "tensorflow/python/pywrap_tensorflow.py", line 52, in <module>
raise ImportError(msg)
ImportError: Traceback (most recent call last):
File "tensorflow/python/pywrap_tensorflow.py", line 41, in <module>
from tensorflow.python.pywrap_tensorflow_internal import *
ImportError: No module named pywrap_tensorflow_internal
Failed to load the native TensorFlow runtime.
I'm working in a virtualenv (using virtualenvwrapper) with up-tp-date packages
python 2.7.10
pip 9.0.1
numpy 1.13.1
wheel 0.29.0
six 1.10.0
I tried to install the default pip package (no GPU support) using pip install tensorflow, first.
Afterwards I also tried to install tensorflow from source following the installation tutorial, without CUDA support (configure script said No CUDA support will be enabled for TensorFlow). Building and installing reported no errors, but I got the same error when I tried to import tensorflow.
Related questions/answers pointed out problems with CUDA or missing Windows dll files, which do not seem to fit my problem.
Any help is welcome. Thanks in advance.
I have the same problem.i did this
First
pip uninstall tensorflow
Download this tensorflow wheel file
Now install this using(in same Directory)
pip install tensorflow-1.6.0-cp36-cp36m-win_amd64.whl
My answer is same to yours.
I deleted the tensorflow with "rm -r ~/tensorflow ",
and finally it working when I have reinstalled it
The detail is here:https://www.tensorflow.org/install/install_mac#CommonInstallationProblems

Which pip is with which python?

This is driving me crazy. I have tried to remove all the packages of python installed on mac os x el capitan and re-installed brew install python and pip. Here I have :
which pip
/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin/pip
and
which python
/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/bin/python
so using pip list
pip list
cycler (0.10.0)
matplotlib (1.5.1)
numpy (1.11.0)
pip (8.1.2)
python-dateutil (2.5.3)
pytz (2016.4)
setuptools (19.4)
six (1.10.0)
wheel (0.26.0)
However, when I run python, there is no module called numpy and matplotlib:
python
Python 2.7.11 (default, Jan 22 2016, 08:29:18)
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named numpy
>>> import matplotlib
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/site-packages/matplotlib/__init__.py", line 122, in <module>
from matplotlib.cbook import is_string_like, mplDeprecation, dedent, get_label
File "/usr/local/lib/python2.7/site-packages/matplotlib/cbook.py", line 33, in <module>
import numpy as np
ImportError: No module named numpy
and this is my sys.path:
sys.path
['', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/usr/local/lib/python2.7/site-packages', '/usr/local/lib/python2.7/site-packages/gtk-2.0']
You can run pip with a specific version of Python by running it as a module. Command line arguments work just as if running directly from the command line. For example, try:
python -m pip list
If that still lists numpy it probably means there is something wrong with the numpy installation — i.e. the .egg file is there, but the module folder is not. To try and fix this you can use --force-reinstall with pip, e.g.
python -m pip install numpy --force-reinstall --upgrade
If that still doesn't work, you can resort to going to the folder reported by sys.path and deleting anything numpy related manually.
Since your pip setup seems messed up you might want to try reinstalling pip too!
The most accurate method is to call pip from the specific python executable. For example:
/usr/bin/python -m pip list -v
/usr/local/bin/python3 -m pip list -v

Categories

Resources