Monthly Shaarli
October, 2021
- Follow this instruction from NVIDIA to install CUDA drivers for WSL.
DO NOT install CUDA Toolkit yet. The version in that instruction is not compatible with current version of Tensorflow/Pytorch.
- Install CUDA Toolkit 11.8.0 for WSL:
wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-wsl-ubuntu.pin
sudo mv cuda-wsl-ubuntu.pin /etc/apt/preferences.d/cuda-repository-pin-600
wget https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda-repo-wsl-ubuntu-11-8-local_11.8.0-1_amd64.deb
sudo dpkg -i cuda-repo-wsl-ubuntu-11-8-local_11.8.0-1_amd64.deb
sudo cp /var/cuda-repo-wsl-ubuntu-11-8-local/cuda-*-keyring.gpg /usr/share/keyrings/
sudo apt-get update
sudo apt-get -y install cuda
Add CUDA to path:
echo 'export PATH=/usr/local/cuda/bin:$PATH' >> ~/.zshrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' >> ~/.zshrc
Symlink libcuda (needed for building darknet):
sudo ln -s /usr/lib/wsl/lib/libcuda.so.1 /usr/local/cuda/lib64/libcuda.so
- Install cuDNN
Go to https://developer.nvidia.com/rdp/cudnn-download and download cuDNN for CUDA 11.x for Linux.
Filename: cudnn-linux-x86_64-8.9.4.25_cuda11-archive.tar.xz
tar -xvf cudnn-linux-x86_64-8.9.4.25_cuda11-archive.tar.xz
cd cudnn-linux-x86_64-8.9.4.25_cuda11-archive
sudo cp -P include/* /usr/local/cuda/include/
sudo cp -P lib/* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*
sudo ldconfig /usr/local/cuda/lib64
-
Install pyenv and create a virtual environment
-
Install Tensorflow and Pytorch:
pip install --upgrade pip setuptools wheel
pip install torch torchvision torchaudio
pip install tensorflow
- Install additional packages (optional):
pip install jupyterlabIn a nutshell: to avoid your shell character set from messing with imports, use -r to export and SOURCE when importing.
Dumping safely
# Do not do this, since it might screw up encoding
mysqldump -uroot -p database > utf8.dump # this is bad
Better do:
mysqldump -uroot -p database -r utf8.dump
Note that when your MySQL server is not set to UTF-8 you need to do mysqldump --default-character-set=latin1 (!) to get a correctly encoded dump. In that case, you will also need to remove the SET NAMES='latin1' comment at the top of the dump, so the target machine won't change its UTF-8 charset when sourcing.
If you only want to dump the structure without data, use
mysqldump -uroot -p --no-data database -r utf8.dump
Importing a dump safely
# Do not do this, since it might screw up encoding
mysql -u username -p database < dump_file # this is bad
Better do:
mysql -uroot -p --default-character-set=utf8mb4 database
mysql> SET names 'utf8';
mysql> SOURCE utf8.dump;
Ref: https://makandracards.com/makandra/595-dumping-and-importing-from-to-mysql-in-an-utf-8-safe-way