tensorflow 2.4.1 创建深度强化学习模型时出错

问题描述

运行此代码

import gym
from os.path import dirname
import random
from tensorflow.keras.layers import *
from tensorflow.keras.models import *
import tensorflow as tf 
import tensorflow.keras as K 
from tensorflow.keras.optimizers import *
import os


env = gym.make('LunarLander-v2')

states = env.observation_space.shape[0]
actions = env.action_space.n
print(actions)

episodes = 15

for episode in range(0,episodes):
    state = env.reset()
    done = False
    score = 0

    while not done:
        env.render()
        action = random.choice([0,1,2,3])
        n_state,reward,done,_ = env.step(action)
        score = score+reward
    print(score,episode)

def build_model(states,actions):
    model = Sequential()
    model.add(Flatten(input_shape=(1,states)))
    model.add(Dense(24,activation='relu'))
    model.add(Dense(24,activation='relu'))
    model.add(Dense(actions,activation='linear'))
    return model
model = build_model(states=states,actions = actions) 
    

我收到这个错误

/home/iyad/anaconda3/bin/python3.8 /home/iyad/myProjects/RL/DRL.py
    2021-02-26 15:06:35.673620: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
    2021-02-26 15:06:35.673644: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.        
    2021-02-26 15:06:59.992010: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices,tf_xla_enable_xla_devices not set
    2021-02-26 15:06:59.992637: W tensorflow/stream_executor/platform/default/dso_loader.cc:60] Could not load dynamic library 'libcuda.so.1'; dlerror: libcuda.so.1: cannot open shared object file: No such file or directory
    2021-02-26 15:06:59.992703: W tensorflow/stream_executor/cuda/cuda_driver.cc:326] Failed call to cuInit: UNKNowN ERROR (303)
    2021-02-26 15:06:59.992775: I tensorflow/stream_executor/cuda/cuda_diagnostics.cc:156] kernel driver does not appear to be running on this host (iyad-ThinkPad-E490): /proc/driver/nvidia/version does not exist
    2021-02-26 15:06:59.993714: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (onednN) to use the following cpu instructions in performance-critical operations:  AVX2 FMA
    To enable them in other operations,rebuild TensorFlow with the appropriate compiler flags.
    2021-02-26 15:06:59.994966: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices,tf_xla_enable_xla_devices not set

我正在尝试创建一个深度强化学习模型,但是我在带有 cpu 的英特尔 I7 中使用 ubuntu 18.04 时遇到了这个错误,你能帮我吗,我需要 tensorflow 才能在我的机器上工作

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)