colab使用问题汇总

在colab上运行自己的项目:

https://zhuanlan.zhihu.com/p/90182331

上传文件每次登录都会消失:

colab使用问题汇总
代码:
from google.colab import drive
drive.mount(’/content/gdrive’)

colab上render gym环境

!apt-get install python-opengl -y

!apt install xvfb -y

!pip install pyvirtualdisplay

!pip install piglet

from pyvirtualdisplay import Display
Display().start()

import gym
from IPython import display
import matplotlib.pyplot as plt
%matplotlib inline

env = gym.make('CartPole-v0')
env.reset()
img = plt.imshow(env.render('rgb_array')) # only call this once
for _ in range(40):
    img.set_data(env.render('rgb_array')) # just update the data
    display.display(plt.gcf())
    display.clear_output(wait=True)
    action = env.action_space.sample()
    env.step(action)

参考链接:https://*.com/questions/50107530/how-to-render-openai-gym-in-google-colab
上一篇:linux下搭建自动化测试环境


下一篇:Gym-102569C Manhattan Distance 曼哈顿距离的转换 二分