Skip to content

Instantly share code, notes, and snippets.

@hfoffani
Last active May 10, 2019 11:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hfoffani/cc8fa20d4ff5022e8d4318f3ed93097e to your computer and use it in GitHub Desktop.
Save hfoffani/cc8fa20d4ff5022e8d4318f3ed93097e to your computer and use it in GitHub Desktop.
minimal gist for installing Swift for TensorFlow

Minimal installation for Swift For TensorFlow.

Run this three scripts in this order:

install_cuda.sh
install_conda.sh
install_python.sh
install_s4tf.sh
#!/bin/bash
# conda
wget https://repo.continuum.io/miniconda/Miniconda3-4.6.14-Linux-x86_64.sh
bash Miniconda3-4.6.14-Linux-x86_64.sh -b
export PATH=~/miniconda3/bin:$PATH
echo '' >> .bashrc
echo '# Conda' >> .bashrc
echo 'export PATH=~/miniconda3/bin:$PATH' >> .bashrc
conda init bash
source ~/.bashrc
#!/bin/bash
sudo add-apt-repository -y ppa:apt-fast/stable
sudo add-apt-repository -y ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install -y ubuntu-drivers-common
ubuntu-drivers devices
sudo apt-get install -y nvidia-driver-430
sudo modprobe nvidia
nvidia-smi
# CUDA
cd
mkdir -p download
cd download
wget https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda_10.0.130_410.48_linux
chmod u+x cuda_10.0.130_410.48_linux
./cuda_10.0.130_410.48_linux --extract=`pwd`
sudo ./cuda-linux.10.0.130-24817639.run -noprompt
echo /usr/local/cuda-10.0/lib64 | sudo tee -a /etc/ld.so.conf
sudo ldconfig
echo 'export PATH=/usr/local/cuda-10.0/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
cd ~/download
wget http://files.fast.ai/files/cudnn-10.0-linux-x64-v7.5.0.56.tgz
tar xf cudnn-10.0-linux-x64-v7.5.0.56.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
sudo ldconfig
#!/bin/bash
# python
conda create -y --name swift python=3.7
conda activate swift
conda install -yc pytorch -c fastai pytorch fastai jupyter
python -c 'import torch; print(torch.tensor(1).cuda())'
jupyter notebook --generate-config
cat << 'EOF' >> ~/.jupyter/jupyter_notebook_config.py
c.NotebookApp.open_browser = False
c.NotebookApp.token = ''
EOF
pip install jupyter_contrib_nbextensions
jupyter contrib nbextension install --user
#!/bin/bash
# Swift for TensorFlow
sudo apt-get install clang libpython-dev libblocksruntime-dev
cd
wget https://storage.googleapis.com/swift-tensorflow-artifacts/releases/latest/swift-tensorflow-RELEASE-LATEST-cuda10.0-cudnn7-ubuntu18.04.tar.gz
tar xf swift-tensorflow-RELEASE-LATEST-cuda10.0-cudnn7-ubuntu18.04.tar.gz
export PATH=$(pwd)/usr/bin:"${PATH}"
echo 'export PATH=$(pwd)/usr/bin:"${PATH}"' >> ~/.bashrc
# Swift Jupyter
git clone https://github.com/google/swift-jupyter.git
cd ~/swift-jupyter
python register.py --sys-prefix --swift-python-use-conda --use-conda-shared-libs --swift-toolchain ~
# fastai swift
cd
git clone https://github.com/fastai/fastai_docs.git
cd fastai_docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment