CUDAのインストール †
→Python CUDA on MacBookPro
CUDA関連の環境変数の設定 (plist) †
- この設定は macOS 10.12 Sierra 以降はこうする
- Cuda関係のライブラリは、$(HOME)/lib:/usr/local/lib/:/lib/:/usr/lib のどこかに Symbolic link を作る
#!/bin/sh
for file in $1/*
do
b=`basename $file`
ln -vs $file ~/lib/$b
done
みたいなシェルスクリプトを作って
[~]$ ./mklink.sh /Developer/NVIDIA/CUDA-9.1/lib
/Users/atsushi/lib/libcublas.9.1.dylib -> /Developer/NVIDIA/CUDA-9.1/lib/libcublas.9.1.dylib
/Users/atsushi/lib/libcublas.dylib -> /Developer/NVIDIA/CUDA-9.1/lib/libcublas.dylib
/Users/atsushi/lib/libcublas_device.a -> /Developer/NVIDIA/CUDA-9.1/lib/libcublas_device.a
/Users/atsushi/lib/libcublas_static.a -> /Developer/NVIDIA/CUDA-9.1/lib/libcublas_static.a
/Users/atsushi/lib/libcudadevrt.a -> /Developer/NVIDIA/CUDA-9.1/lib/libcudadevrt.a
/Users/atsushi/lib/libcudart.9.1.dylib -> /Developer/NVIDIA/CUDA-9.1/lib/libcudart.9.1.dylib
...
CuPy?のインストール †
$ git clone https://github.com/cupy/cupy.git
$ cd cupy
$ git checkout v4.2.0
$ python setup.py clean
$ MACOSX_DEPLOYMENT_TARGET=10.13 CC=clang CXX=clang++ python setup.py install
$ pip install .
Processing /Users/atsushi/PycharmProjects/cupy
Requirement already satisfied: numpy>=1.9.0 in /Users/atsushi/.pyenv/versions/anaconda3-5.1.0/envs/jupyter-env/lib/python3.6/site-packages (from cupy==4.2.0) (1.14.3)
Requirement already satisfied: six>=1.9.0 in /Users/atsushi/.pyenv/versions/anaconda3-5.1.0/envs/jupyter-env/lib/python3.6/site-packages (from cupy==4.2.0) (1.11.0)
Requirement already satisfied: fastrlock>=0.3 in /Users/atsushi/.pyenv/versions/anaconda3-5.1.0/envs/jupyter-env/lib/python3.6/site-packages (from cupy==4.2.0) (0.3)
Building wheels for collected packages: cupy
Running setup.py bdist_wheel for cupy ... done
Stored in directory: /private/var/folders/cm/p00lclws0jxdmjlb89qyqq580000gn/T/pip-ephem-wheel-cache-47vpnvhd/wheels/f3/4b/b6/cf3092440fb9ebf35bfb25a4de43ee2a9609fae446258288e9
Successfully built cupy
Installing collected packages: cupy
Found existing installation: cupy 4.2.0
Uninstalling cupy-4.2.0:
Successfully uninstalled cupy-4.2.0
Successfully installed cupy-4.2.0
なんか動いた †
import cupy as cp
a = cp.array([1,2,3,4,5])
b = cp.array([6,7,8,9,10])
c = a + b
print (c)
[ 7 9 11 13 15]
Python