之前复现的tensorflow框架网络用gpu跑起来了

之前复现的tensorflow框架网络一直用cpu跑起来的,跑一轮要好几个小时,其实原本以为是用gpu跑的,结果仔细查看后没有用到gpu,

/home/chengj/anaconda3/envs/3dUnet/bin/python /home/chengj/student/lhh/Keras-Brats-Improved-Unet3d-master/brats/train_isensee2017.py 
/home/chengj/anaconda3/envs/3dUnet/lib/python3.6/site-packages/nilearn/__init__.py:69: FutureWarning: Python 3.6 support is deprecated and will be removed in release 0.10 of Nilearn. Consider switching to Python 3.8 or 3.9.
  _python_deprecation_warnings()
Using TensorFlow backend.
/home/chengj/anaconda3/envs/3dUnet/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:523: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
/home/chengj/anaconda3/envs/3dUnet/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:524: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
/home/chengj/anaconda3/envs/3dUnet/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:525: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
/home/chengj/anaconda3/envs/3dUnet/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
/home/chengj/anaconda3/envs/3dUnet/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:527: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
/home/chengj/anaconda3/envs/3dUnet/lib/python3.6/site-packages/tensorflow/python/framework/dtypes.py:532: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])
1.12.0
Loading pre-trained model
2024-10-21 15:23:18.827556: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
Loading previous validation split...
Number of training steps:  1285
Number of validation steps:  173
Epoch 1/500
2024-10-21 15:23:36.040941: W tensorflow/core/framework/allocator.cc:122] Allocation of 905969664 exceeds 10% of system memory.
2024-10-21 15:23:36.040939: W tensorflow/core/framework/allocator.cc:122] Allocation of 905969664 exceeds 10% of system memory.
2024-10-21 15:23:36.364044: W tensorflow/core/framework/allocator.cc:122] Allocation of 905969664 exceeds 10% of system memory.
2024-10-21 15:23:36.364091: W tensorflow/core/framework/allocator.cc:122] Allocation of 905969664 exceeds 10% of system memory.
2024-10-21 15:23:37.278519: W tensorflow/core/framework/allocator.cc:122] Allocation of 452984832 exceeds 10% of system memory.
 385/1285 [=======>......................] - ETA: 35:19 - loss: -0.7663

而后想办法怎么用gpu跑,遇到报错:

Using TensorFlow backend.
Traceback (most recent call last):
  File "/home/chengj/anaconda3/envs/3dUnet/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/home/chengj/anaconda3/envs/3dUnet/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/home/chengj/anaconda3/envs/3dUnet/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 "/home/chengj/anaconda3/envs/3dUnet/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/home/chengj/anaconda3/envs/3dUnet/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: libcublas.so.9.0: 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/chengj/student/lhh/Keras-Brats-Improved-Unet3d-master/brats/train.py", line 9, in <module>
    from keras import backend as K
  File "/home/chengj/anaconda3/envs/3dUnet/lib/python3.6/site-packages/keras/__init__.py", line 3, in <module>
    from . import utils
  File "/home/chengj/anaconda3/envs/3dUnet/lib/python3.6/site-packages/keras/utils/__init__.py", line 6, in <module>
    from . import conv_utils
  File "/home/chengj/anaconda3/envs/3dUnet/lib/python3.6/site-packages/keras/utils/conv_utils.py", line 9, in <module>
    from .. import backend as K
  File "/home/chengj/anaconda3/envs/3dUnet/lib/python3.6/site-packages/keras/backend/__init__.py", line 89, in <module>
    from .tensorflow_backend import *
  File "/home/chengj/anaconda3/envs/3dUnet/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py", line 5, in <module>
    import tensorflow as tf
  File "/home/chengj/anaconda3/envs/3dUnet/lib/python3.6/site-packages/tensorflow/__init__.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow  # pylint: disable=unused-import
  File "/home/chengj/anaconda3/envs/3dUnet/lib/python3.6/site-packages/tensorflow/python/__init__.py", line 49, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/home/chengj/anaconda3/envs/3dUnet/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/chengj/anaconda3/envs/3dUnet/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow.py", line 58, in <module>
    from tensorflow.python.pywrap_tensorflow_internal import *
  File "/home/chengj/anaconda3/envs/3dUnet/lib/python3.6/site-packages/tensorflow/python/pywrap_tensorflow_internal.py", line 28, in <module>
    _pywrap_tensorflow_internal = swig_import_helper()
  File "/home/chengj/anaconda3/envs/3dUnet/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 "/home/chengj/anaconda3/envs/3dUnet/lib/python3.6/imp.py", line 243, in load_module
    return load_dynamic(name, filename, file)
  File "/home/chengj/anaconda3/envs/3dUnet/lib/python3.6/imp.py", line 343, in load_dynamic
    return _load(spec)
ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory


Failed to load the native TensorFlow runtime.

See https://www.tensorflow.org/install/errors

for some common reasons and solutions.  Include the entire stack trace
above this error message when asking for help.

反正是后来一顿chatgpt,找到自己需要的cuda和cudnn版本进行配置:

conda install cudnn=7.6
conda install cudatoolkit=9.0

我的tensorflow版本是 TensorFlow 1.12.0,

(可以查看这个博客看不同版本框架的对于版本:Win11极速安装Tensorflow-gpu+CUDA+cudnn_win11安装tensorflow-优快云博客

(这个视频也可以学习:

10分钟内快速安装Tensorflow-gpu+cuda+ cudnn的方法_哔哩哔哩_bilibili

gpu跑的真快呀

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值