简体   繁体   English

当我运行下面的程序时,在带有 ROCm 的 AMD GPU 上使用 Tensorflow 和 Keras 使用 Python 进行深度学习会出错

[英]Deep Learning with Python using Tensorflow and Keras on AMD GPU with ROCm gives errors when I run the program below

I have an AMD GPU pc which I have recently started to use with Linux Mint OS I've seen a way of installing ROCm on this pc following this tutorial, but when I tried to write a Python program using Keras it threw these errors.我有一台 AMD GPU 电脑,我最近开始在 Linux Mint 操作系统上使用它,我看到了一种在教程之后在这台电脑上安装 ROCm 的方法,但是当我尝试使用 Keras 编写 Python 程序时,它抛出了这些错误。 Here is my code:这是我的代码:

import numpy as np
from numpy import genfromtxt
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import MinMaxScaler
from keras.models import Sequential
from keras.layers import Dense

data=genfromtxt('../DATA/bank_note_data.txt',delimiter=',')
labels=data[:,4]
features=data[:,0:4]
X=features
y=labels 

X_train, X_test, y_train, y_test = train_test_split(X,y,test_size=0.33,random_state=42)

scalerObject=MinMaxScaler()
scalerObject.fit(X_train)
scaled_X_train=scalerObject.transform(X_train)
scaled_X_test=scalerObject.transform(X_test)

model=Sequential()
model.add(Dense(4,input_dim=4,activation='relu'))
model.add(Dense(8,activation='relu'))
model.add(Dense(1,activation='sigmoid'))

model.compile(loss='binary_crossentropy',optimizer='adam',metrics=['accuracy'])

model.fit(scaled_X_train,y_train,epochs=50,verbose=2)
print(model.fit(scaled_X_train,y_train,epochs=50,verbose=2))

These were the errors:这些是错误:

Traceback (most recent call last):
  File "/home/cemosambora/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/home/cemosambora/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/home/cemosambora/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/usr/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/usr/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: librccl.so: cannot open shared object file: No such file or directory

During handling of the above exception, another exception occurred:在处理上述异常的过程中,又发生了一个异常:

Traceback (most recent call last):
  File "/home/cemosambora/eclipse-workspace/Deep_Learning_OpenCV/kerasBasics.py", line 5, in <module>
    from keras.models import Sequential
  File "/home/cemosambora/.local/lib/python3.6/site-packages/keras/__init__.py", line 3, in <module>
    from . import utils
  File "/home/cemosambora/.local/lib/python3.6/site-packages/keras/utils/__init__.py", line 6, in <module>
    from . import conv_utils
  File "/home/cemosambora/.local/lib/python3.6/site-packages/keras/utils/conv_utils.py", line 9, in <module>
    from .. import backend as K
  File "/home/cemosambora/.local/lib/python3.6/site-packages/keras/backend/__init__.py", line 89, in <module>
    from .tensorflow_backend import *
  File "/home/cemosambora/.local/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 5, in <module>
    import tensorflow as tf
  File "/home/cemosambora/.local/lib/python3.6/site-packages/tensorflow/__init__.py", line 28, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "/home/cemosambora/.local/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/home/cemosambora/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 74, in <module>
    raise ImportError(msg)
ImportError: Traceback (most recent call last):
  File "/home/cemosambora/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/home/cemosambora/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/home/cemosambora/.local/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow_internal', fp, pathname, description)
  File "/usr/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/usr/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: librccl.so: cannot open shared object file: No such file or directory


Failed to load the native TensorFlow runtime.

This page has some common reasons and solutions.此页面有一些常见的原因和解决方案。

This error was caused by missing rccl library.此错误是由缺少 rccl 库引起的。 After installing rocm, you need to install some ROCm Libraries :安装 rocm 后,您需要安装一些 ROCm 库:

sudo apt-get update && sudo apt-get install -y --allow-unauthenticated  rocm-dkms rocm-dev rocm-libs rccl rocm-device-libs hsa-ext-rocr-dev hsakmt-roct-dev hsa-rocr-dev rocm-opencl rocm-opencl-dev   rocm-utils  rocm-profiler cxlactivitylogger miopen-hip miopengemm

Bit late to respond, but here's my two-cents for what it may be worth.回复有点晚,但这是我的两美分可能值得。 It is highly recommended that we use Ubuntu 18.04 per the pre-requisites and official support offered by ROCm Considering the holistic aspects of the way many eco-system oriented support that you might bump onto in this regard vis-a-vis Python Packages, GPU Support etc., this should be the best bet for you to consider;强烈建议大家使用Ubuntu 18.04每所提供的先决条件和官方支持的ROCm考虑的方式整体方面的许多生态系统支持导向,你可能会碰到在这方面的面对面的人Python包,GPU支持等,这应该是您考虑的最佳选择; should you be serious about your endeavour in this regard.你是否应该认真对待你在这方面的努力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM