Last active
April 27, 2018 00:23
-
-
Save daveselinger/54f5c131064555ab53c8ded1c00f842a to your computer and use it in GitHub Desktop.
Ubuntu 16.04 AMD + OpenCL + Theano + Keras from scratch (IN PROGRESS)
This file contains hidden or 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
## Shout out to jarutis here https://gist.github.com/jarutis/ff28bca8cfb9ce0c8b1a | |
## install Catalyst proprietary | |
## sudo cp /etc/X11/xorg.conf /etc/X11/xorg.conf.BAK | |
# on a clean install not needed but could be helpful | |
sudo apt-get remove --purge fglrx* | |
# | |
sudo add-apt-repository ppa:oibaf/graphics-drivers | |
sudo apt update | |
sudo apt install mesa-vdpau-drivers | |
sudo apt install mesa-opencl-icd | |
## install build essentials | |
sudo apt install linux-headers-generic cmake build-essential git | |
# Some mesa drivers can get upgraded | |
sudo apt upgrade | |
## Need to download this from here: http://developer.amd.com/amd-accelerated-parallel-processing-app-sdk/ | |
# because it requires a browser, you can either download using Xwindows, or I download on my mac and then SCP it to the machine: | |
# scp ~/Downloads/AMD-APP-SDKInstaller-v3.0.130.136-GA-linux32.tar.bz2 ubuntu@IPADDRESS_x.xx.xx.xx:~/Downloads | |
## install AMD APP SDK from ~/Downloads | |
## Accept the license and install in /opt | |
cd ~/Downloads | |
tar xjf AMD-APP-SDKInstaller-v3.0.130.136-GA-linux64.tar.bz2 | |
sudo ./AMD-APP-SDK-v3.0.130.136-GA-linux64.sh | |
## install libgpuarray | |
sudo apt-get install libboost-all-dev libgtest-dev | |
cd /usr/src/gtest | |
sudo mkdir build | |
cd build | |
sudo cmake .. | |
sudo make | |
sudo mv libg* /usr/lib/ | |
## download AMD acml library | |
### mkdir ~/Ini | |
#### tar -xvf acml-6.1.0.31-gfortran64.tgz -C ~/Ini/acml | |
#### echo "###################################################################" >> ~/.bashrc | |
###### echo "export ACML_ROOT=/home/jjarutis/Ini/acml" >> ~/.bashrc | |
###### export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"/home/jjarutis/Ini/acml/gfortran64/lib" >> ~/.bashrc | |
# clBlas dependency... | |
sudo apt install libclblas2 libclblas-bin libclblas-dev libclblas-doc | |
sudo update-pciids | |
cd ~/Downloads | |
git clone https://github.com/Theano/libgpuarray.git | |
cd libgpuarray | |
git checkout v0.6.9 | |
mkdir build | |
cd build | |
cmake .. -DCMAKE_BUILD_TYPE=Release -DOPENCL_INCLUDE_DIRS=/opt/AMDAPPSDK-3.0/include/ | |
make | |
sudo make install | |
cd .. | |
sudo apt install python-dev python3-dev python-pip python3-pip python-nose python3-nose g++ libopenblas-dev | |
sudo pip install cython numpy scipy | |
sudo pip3 install cython numpy scipy | |
python3 setup.py build | |
sudo python3 setup.py install | |
python setup.py build | |
sudo python setup.py install | |
## Theano | |
sudo pip install Theano | |
sudo pip3 install Theano | |
## Now for some reason the libgpu shared objects end up in /usr/local/lib and python only looks in /usr/lib by default so... :) | |
sudo mv /usr/local/lib/libgpuarray* /usr/lib | |
## Now it appears we need to install ffi | |
sudo apt install libffi-dev | |
sudo pip3 install cffi==1.5.2 | |
sudo pip3 install pyopencl | |
sudo pip install cffi==1.5.2 | |
sudo pip install pyopencl | |
THEANO_FLAGS=device=opencl0:0 python test.py | |
THEANO_FLAGS=device=opencl0:0 python3 test.py |
To use this to run the on-board Asus Intel HD graphics card (after OpenCL installation):
- Install libgpuarray v0.6.9 only, as above
- Install Theano 0.10.0b1
For Snapdragon, replace
pip install cython
with
sudo pip install Cython --install-option="--no-cython-compile"
How can we get this to work with Ubuntu 16.04 and newer radeon cards since the drivers update?
where did you find the file acml-6.1.0.31-gfortran64.tgz?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This works for libgpuarray v0.6.9 and theano 0.9.0!