Work remotely with PyCharm, TensorFlow and SSH

Remote data crunching machine

Hopefully your remote machine doesn’t look like this.
sudo apt-get install ssh
sudo gedit /etc/ssh/sshd_config
# X11Forwarding yes
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-367
sudo dpkg -i cuda-repo-ubuntu1604_8.0.44-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda-toolkit-8.0
readlink -f /usr/local/cuda
>> /usr/local/cuda-8.0
tar xvzf cudnn-8.0-linux-x64-v5.1.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
echo 'export LD_LIBRARY_PATH=”$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"' >> ~/.bashrc
echo 'export CUDA_HOME=/usr/local/cuda' >> ~/.bashrc
source ~/.bashrc
sudo apt-get install python-pip python-dev build-essential python-numpy python-scipy python-matplotlib
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.11.0rc2-cp27-none-linux_x86_64.whl
pip install --ignore-installed --upgrade $TF_BINARY_URL
python
import tensorflow
>I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcublas.so locally
>I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcudnn.so locally
>I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcufft.so locally
>I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcuda.so.1 locally
>I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcurand.so locally

Super sleek ultrabook

/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"brew tap caskroom/cask
brew install cask ssh-copy-id python
brew cask install java pycharm xquartz
ssh-keygen -t rsa
ssh-copy-id [remote username here]@[remote Ip here]
echo 'ForwardX11 yes' >> ~/.ssh/config
echo 'Compression yes' >> ~/.ssh/config
ssh [remote username here]@[remote Ip here]
sudo vim /etc/ssh/sshd_config
PasswordAuthentication no
service ssh restart
echo $DISPLAY
> localhost:10.0

Remote interpreter in PyCharm

import tensorflow
print "Tensorflow Imported"

Testing the setup

ssh [remote username here]@[remote Ip here]
import tensorflow
import matplotlib
matplotlib.use('GTKAgg')
import matplotlib.pyplot as plt
import numpy as np

print "Tensorflow Imported"
plt.plot(np.arange(100))
plt.show()

Next step

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store