Elixir用WSL構築記録(個人的メモ)

個人的メモです

ベースはubuntu-22.04

```Ps:import command
> wsl --import elixir d:\wsl\elixir D:\ubuntu-22.04.tar
```


```conf:/etc/wsl.conf
[user]
default=masa

[boot]
systemd=true

[network]
generateResolvConf = true
hostname = wsl-elixir
```

```
sudo apt update
sudo apt-get -y install build-essential autoconf m4 libncurses5-dev libwxgtk3.0-gtk3-dev libwxgtk-webview3.0-gtk3-dev libgl1-mesa-dev libglu1-mesa-dev libpng-dev libssh-dev unixodbc-dev xsltproc fop libxml2-utils libncurses-dev openjdk-11-jdk
#install asdf
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch v0.10.2
echo ". $HOME/.asdf/asdf.sh" >> ~/.bashrc
source ~/.asdf/asdf.sh
#install arlang
asdf plugin add erlang
asdf install erlang 25.1.1
asdf global erlang 25.1.1
#install elixir
asdf plugin add elixir
asdf install elixir 1.14.2-otp-25
asdf global elixir 1.14.2-otp-25
#install nodejs
asdf plugin add nodejs
asdf install nodejs 19.0.0
asdf global nodejs 19.0.0
#python
asdf plugin add python
asdf install python 3.11.0
asdf global python 3.11.0
#install cuda
sudo apt-key del 7fa2af80
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
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/3bf863cc.pub
sudo add-apt-repository 'deb https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/ /'
sudo apt-get update
sudo apt-get -y install cuda=11.1.0-1 #バージョン指定する
export XLA_TARGET=cuda111
echo "export XLA_TARGET=cuda111" >> ~/.bashrc
# copy ssh key from windows user dir
cp -r /mnt/c/Users/masat/.ssh/ ~/
chmod 600 ~/.ssh/*
# other
sudo apt-get install inotify-tools
```


`pip install gym[atari]`がエラーになるので、asdfのpythonを削除、venvインストール
```
asdf uninstall python
asdf plugin remove python
sudo apt install python3.10-venv
```

dockerをインストール
https://docs.docker.com/engine/install/ubuntu/
```
sudo apt-get update
sudo apt-get install \
    ca-certificates \
    curl \
    gnupg \
    lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update

sudo chmod a+r /etc/apt/keyrings/docker.gpg
sudo apt-get update

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
```

Elixir desktopがWSLgで表示されない問題の回避策
```
export export GDK_BACKEND=x11
echo "eexport GDK_BACKEND=x11" >> ~/.bashrc
```

WSL版のcudaには、libcudnnが入ってないので、Ubuntu版のlibcudnnをインストール
```
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/libcudnn8-dev_8.7.0.84-1+cuda11.8_amd64.deb
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/libcudnn8_8.7.0.84-1+cuda11.8_amd64.deb
sudo apt install ./libcudnn8-dev_8.7.0.84-1+cuda11.8_amd64.deb ./libcudnn8_8.7.0.84-1+cuda11.8_amd64.deb
```
axon_rl_demo 動作させるために、python3-dev追加
```
$ sudo apt install python3-dev
```
Elisir/erlangのバージョンアップ
```
asdf install erlang 27.0
asdf global erlang 27.0
asdf install elixir 1.16.3-otp-26
asdf global elixir 1.16.3-otp-26
```

mDNSを使えるようにする
```
sudo apt-get install libnss-mdns
```

petalinuxのインストールで必要なパッケージを追加
```
sudo apt-get install xterm libtool texinfo gcc-multilib
```

```
sudo apt-get install tofrodos gawk xvfb git libncurses5-dev tftpd zlib1g-dev zlib1g-dev:i386 libssl-dev flex bison chrpath socat autoconf libtool texinfo gcc-multilib libsdl1.2-dev libglib2.0-dev screen pax
```