代码遇到的问题

2023/6/4

问题一:read_csv路径
最初版本:data=pd.read_csv(r'ohio/ohio570_Testing.csv')路径是csv的相对路径
报错:找不到文件
解决:路径改为data=pd.read_csv(r'ohio570_Testing.csv')运行成功
原因:已经进了ohio文件夹,不能再导入这个路径

2023/6/5

问题一:tensorflow版本过高没有某个包
https://devdocs.io/tensorflow~2.3/
https://devdocs.io/tensorflow~1.15/
对比不同版本tensorflow里面的包可以找到对应包所在的库
问题二:安装keras_gpu时报错
An unexpected error has occurred. Conda has prepared the above report.
If submitted, this report will be used by core maintainers to improve future releases of conda.
Would you like conda to send this report to the core maintainers?
解决:梯子关掉

2023/6/6

问题一:运行代码报错
No OpKernel was registered to support Op ‘CudnnRNNV2’ used by {{node model/cu_dnnlstm/CudnnRNNV2}} with these attrs: [dropout=0, seed=0, input_mode=“linear_input”, T=DT_FLOAT, direction=“unidirectional”, rnn_mode=“lstm”, is_training=true, seed2=0]
Registered devices: [CPU, XLA_CPU]
Registered kernels:
[No registered kernels]

由于没有显示GPU上可用,所以首先安装了一个缺失文件cudart64_101.dll 到cuda的bin目录下,报错变为:
No OpKernel was registered to support Op ‘CudnnRNNV2’ used by {{node model/cu_dnnlstm/CudnnRNNV2}} with these attrs: [dropout=0, seed=0, input_mode=“linear_input”, T=DT_FLOAT, direction=“unidirectional”, rnn_mode=“lstm”, is_training=true, seed2=0]
Registered devices: [CPU, XLA_CPU]
Registered kernels:
device=‘GPU’; T in [DT_HALF]
device=‘GPU’; T in [DT_FLOAT]
device=‘GPU’; T in [DT_DOUBLE]
问题二:配完环境初始报错
报错:No module named util
pip utils依旧报错
原因:配置环境后没有安装python
问题三:训练中间报错
报错:tensorflow.python.framework.errors_impl.InternalError: 2 root error(s) found.
Blas GEMM launch failed
原因:显存分配问题,更改为动态分配内存就可以解决。在训练的脚本开头添加以下代码即可进行内存的动态分配,重新运行即可。
解决:在运行文件开头加入代码段设置GPU内存

config = tf.ConfigProto()
config.gpu_options.allow_growth = True      # TensorFlow按需分配显存
config.gpu_options.per_process_gpu_memory_fraction = 0.5  # 指定显存分配比例
keras.backend.tensorflow_backend.set_session(tf.Session(config=config))

还是报错,然后将代码段改成设置最小的GPU使用量

###显卡设置
os.environ["CUDA_VISIBLE_DEVICES"] = "0"
###设置最小的GPU使用量
config = tf.ConfigProto() 
config.gpu_options.allow_growth = True 
session = tf.Session(config=config)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值