TensorFlow:升级TensorFlow2.3踩坑记录(Python)

升级TensorFlow2.3踩坑记录(Python)


前言

原本是使用的TensorFlow2.0,处理时间序列数据时发现一个很好用的函数:tf.keras.preprocessing.timeseries_dataset_from_array。不料报错没有此函数,才知道这个函数要TensorFlow2.3及以上才有,于是打算升级至TensorFlow2.3,过程中踩了几个坑,记录一下。


一、CUDA版本问题

原本使用的是CUDA10.0,看官网信息这样显示:TensorFlow 支持 CUDA® 10.1(TensorFlow 2.1.0 及更高版本)。想着一般CUDA是向下兼容的,于是直接把CUDA升级到了11.0,以免后面还要再升级CUDA。可是当我所有环境配置好之后显示这样的错误:

Could not load dynamic library ‘cudart64_101.dll’; dlerror: cudart64_101.dll not found

百思不得其解,查找资料发现CUDA版本只能是10.1,高一点都不行,遂重装。

这里分享一个小技巧,我们在下载CUDA时候网速会特别慢 ,我们只需要将下载链接复制到迅雷用迅雷下载就很快了。

二、GPU支持问题

CUDA版本问题解决了,开开心心运行TensorFlow,本以为可以顺利运行,但是又报了一个如下错误:

InternalError: CUDA runtime implicit initialization on GPU:0 failed. Status: device kernel image is invalid

找了半天才发现这个错误官网已经提示过:

The error message “Status: device kernel image is invalid” indicates that the TensorFlow package does not contain PTX for your architecture. You can enable compute capabilities by building TensorFlow from source.

白话就是TensorFlow2.3已经不支持老版本的GPU,需要通过从原代码构建TensorFlow来安装,直接爆炸,我用的是笔记本,GPU是GTX 960m,是旧了点,但是这也太无语了,如何通过原代码构建TensorFlow的教程链接在这里。我的选择是放弃,转回安装TensorFlow2.2。至于那个好用的函数,只能用tf.keras.preprocessing.sequence.TimeseriesGenerator代替了。

总结

Pytorch yes

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章