openai / gym

A toolkit for developing and comparing reinforcement learning algorithms.
https://www.gymlibrary.dev
Other
34.2k stars 8.58k forks source link

Juputer notebook Kernel Dead After running any gym method #3252

Open AasheeshLikePanner opened 7 months ago

AasheeshLikePanner commented 7 months ago

Describe the bug The bug is when i run the code it show's me the kernel is dead and restarting the main issue i found is the env method i created and running any gym method like env.render or env.action_space.sample() or env.close(). After I comment all this code or line then the code running fine but after running it without comment kernel will dead.

Code

import gym
from stable_baselines3 import PPO
from stable_baselines3.common.vec_env import DummyVecEnv
from stable_baselines3.common.evaluation import evaluate_policy
from IPython.display import display, clear_output

enviroment_name = 'CartPole-v1'
env = gym.make(enviroment_name, render_mode = 'human')

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

    while not done:
        env.render()
        action = env.action_space.sample()
        n_state, reward, truncate, done, info = env.step(action)
        score += reward
    print('Episode:{} Score:{}'.format(episodes,score))
env.close()

Also console showing this:

KernelRestarter: restarting kernel (1/5), keep random ports
WARNING:root:kernel a23dd0d8-4dd7-4aac-a008-8736e29ab8c1 restarted
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.

System Info i installed gym as pip install gym Describe the characteristic of your environment: i my enviroment i installed tensorflow and pytorch and most of the other things also cude is enabled in my enviroment.

Additional context I have checked the issue but still my problem isn't solved.

Checklist