Install ROCm on Ubuntu 18.04 for RX5700XT

I really regret I bought this RX5700XT. Now I have problems doing everything. It has green screen and rebooting problems under Windows, so I have to change the OS. While, I want to use it for learning machine learning anyway. So, I started to install TensorFlow for AMD GPU.

Firstly, go to its GitHub page and read the introductions.

https://rocm.github.io/ROCmInstall.html

Since I am using Ubuntu 18.04, I need to use the upstream kernel driver because rock-dkms kernel may not be compatible. Follow the commands of “Ubuntu Support – installing from a Debian repository”.

BTW, I got “no GPU devices” after running “/opt/rocm/bin/rocminfo”, that is because I have not installed the GPU driver. And, the green screen and rebooting thing still happens a lot.

Go to AMD, download and install the driver for Ubuntu, reboot.

Run the command again, it should work.

Then, install TensorFlow for ROCm, follow the commands in “ROCm Tensorflow Official Releases” from https://rocm.github.io/tensorflow.html

Then, run a test.

from future import absolute_import, division, print_function, unicode_literals
 Install TensorFlow
 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(input_shape=(28, 28)),
   tf.keras.layers.Dense(128, activation='relu'),
   tf.keras.layers.Dropout(0.2),
   tf.keras.layers.Dense(10, activation='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, verbose=2)


Leave a Reply

Your email address will not be published. Required fields are marked *