Since Ubuntu 20.04 can now perform stable deep learning, record the installation method
Ubuntu 20.04 LTS, like Ubuntu 18.04, is incompatible with Nvidia's GPU The screen will look like the one below
The workaround is to disable the default driver nouveau
during installation or on the GRUB screen to prevent it from freezing.
On this screen, hover over Install Ubuntu and press e
Where it says quiet splash ---
You can disable nouveau
by rewritingquiet splash nomodeset ---
.
After rewriting, start running with the options updated with Ctrl-x
Install according to the instructions. If you install additional drivers etc. instead of the minimum configuration, Recommended because nvidia-driver is included.
Since the same problem occurs after installation, there are cases where nomodeset support is required (especially when a login loop occurs when automatic login is enabled).
Press ctrl + alt + F2
on the login screen to enter the CLI login screen.
Enter username and password and execute the process corresponding to nomodeset
sudo vi /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
Where it is
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
To
#Apply changes
sudo update-grab
# nvidia-Insert the driver
sudo apt install nvidia-driver-440;
#Reboot
sudo reboot
At this point the driver is in.
$ nvidia-smi
Tue Sep 15 18:56:00 2020
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 440.100 Driver Version: 440.100 CUDA Version: 10.2 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce RTX 208... Off | 00000000:01:00.0 Off | N/A |
| 41% 31C P8 13W / 250W | 311MiB / 10997MiB | 0% Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 973 G /usr/lib/xorg/Xorg 175MiB |
| 0 1339 G /usr/bin/gnome-shell 120MiB |
| 0 3263 G /usr/lib/firefox/firefox 6MiB |
| 0 3787 G gnome-control-center 6MiB |
+-----------------------------------------------------------------------------+
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y vim csh flex gfortran git g++ cmake xorg-dev patch zlib1g-dev libbz2-dev libboost-all-dev openssh-server libcairo2 libcairo2-dev libeigen3-dev lsb-core lsb-base net-tools network-manager xclip gdebi-core libffi-dev make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
Pass through
$ vim ~/.bashrc
#Add the following to the end
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
$ source ~/.bashrc
Install your favorite Python version
$ pyenv install 3.6.9
$ pyenv global 3.6.9
$ pyenv rehash
$ python -V
Python 3.6.9
$ mkdir -p ~/workspace/test
$ cd ~/workspace/test
$ python -m venv venv36tf
$ source venv36tf/bin/activate
$ pip install --upgrade pip
$ pip install tensorflow-gpu==2.2
mnist experiment
Save the following as test_mnist.py
test_mnist.py
import tensorflow as tf
mnist = tf.keras.datasets.mnist
(x_train, y_train),(x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0
model = tf.keras.models.Sequential([
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(512, activation=tf.nn.relu),
tf.keras.layers.Dropout(0.2),
tf.keras.layers.Dense(10, activation=tf.nn.softmax)
])
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
model.fit(x_train, y_train, epochs=5)
model.evaluate(x_test, y_test)
Run Success if the output is as follows
$ python test_mnist.py
Epoch 1/5
1875/1875 [==============================] - 1s 768us/step - loss: 0.2215 - accuracy: 0.9337
Epoch 2/5
1875/1875 [==============================] - 1s 733us/step - loss: 0.0980 - accuracy: 0.9700
Epoch 3/5
1875/1875 [==============================] - 1s 739us/step - loss: 0.0711 - accuracy: 0.9780
Epoch 4/5
1875/1875 [==============================] - 1s 738us/step - loss: 0.0562 - accuracy: 0.9821
Epoch 5/5
1875/1875 [==============================] - 1s 736us/step - loss: 0.0437 - accuracy: 0.9861
313/313 [==============================] - 0s 608us/step - loss: 0.0613 - accuracy: 0.9816
Recommended Posts