运行此代码后
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 才能在我的机器上工作