keras with pytorch backend : GPU版

发布时间:2024年01月07日

1. My OS is Ubuntu 20.04

2. Install cuda 12.2.0 (cuda_12.2.0_535.54.03_linux.run) as well as NIVDIA Driver 535

3. Install cudnn(cudnn-local-repo-ubuntu2004-8.9.7.29_1.0-1_amd64.deb)

4.?download two requirement files form keras github homepage:

  • requirements-common.txt
  • requirements-torch-cuda.txt

5. create a conda env

conda create -y -n keras-pytorch python=3.103.10
conda activate keras-pytorchtorch
pip install -r requirements-torch-cuda.txt
pip install keras --upgrade

?6. test & usage:

import os
import torch
# To test running torch with GPU or not
torch.cuda.is_available()        # if GPU is sucessfully, it will return True
# select pytorch as keras backend
os.environ["KERAS_BACKEND"] = "torch"
import keras
# To check keras backend and keras version
keras.backend.backend()
keras.__version__

文章来源:https://blog.csdn.net/herokoking/article/details/135445512
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。