Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CUDA_ERROR_NOT_INITIALIZED when trying to use a GPU accelerated environment #137

Closed
Sephirex-X opened this issue Nov 6, 2023 · 0 comments

Comments

@Sephirex-X
Copy link

Sephirex-X commented Nov 6, 2023

Hi, very impressive work, however when I try to use a GPU accelerated env I got error like CUDA_ERROR_NOT_INITIALIZED.

The env I used is accelerated by tensorflow and it works pretty well seperately. After a few troubleshoots I noticed that ur work somehow use multiprocess to accelerate data collection on env, therefore I believe the error roots from the confilct between multiprocess and CUDA initialization, I'm wonder if your guys could provide some info to help me out.

thx a lot
here is my code

import eveything
@ENV_REGISTRY.register('myenv')
class Myenv(BaseEnv):
    def __init__(self, cfg: dict) -> None:
       #doing something related to gpu mainly initialization
    def reset(self):
        #doing reset
        lightzero_obs_dict = {'observation': obs, 'action_mask': self.action_mask, 'to_play': -1}
        return lightzero_obs_dict
    def step(self, action):
        #doing env step
        return BaseEnvTimestep(lightzero_obs_dict, rew, done, info)
        
    def seed(self, seed: int, dynamic_seed: bool = True) -> None:
        self._seed = seed
        self._dynamic_seed = dynamic_seed
        np.random.seed(self._seed)
    
    def close(self) -> None:
        if self._init_flag:
            pass
        self._init_flag = False

    def __repr__(self) -> str:
        return "My Env"

    @property
    def observation_space(self) -> gym.spaces.Space:
        return self._observation_space

    @property
    def action_space(self) -> gym.spaces.Space:
        return self._action_space
    
    @property
    def reward_space(self) -> gym.spaces.Space:
        return self._reward_space
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant