Skip to content

Conversation

@jacobarrio
Copy link

Fixes the three issues reported in #289:

Import path was broken - removed the second arg from try_import since AtariEnv gets imported directly later anyway (line 31).

ale_py pinned to 0.9.0 but that doesn't have Python 3.13 wheels. Bumped to >=0.10.1.

num_workers hardcoded to 16 in atari.ini causes errors on machines with fewer cores. Changed to 0 for auto-detection.

Tested the import and verified no worker errors locally.

Closes #289

[vec]
num_envs = 128
num_workers = 16
num_workers = 0
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /puffertank/venv/bin/puffer:10 in <module>                                                       │
│                                                                                                  │
│    7 │   │   sys.argv[0] = sys.argv[0][:-11]                                                     │
│    8 │   elif sys.argv[0].endswith(".exe"):                                                      │
│    9 │   │   sys.argv[0] = sys.argv[0][:-4]                                                      │
│ ❱ 10 │   sys.exit(main())                                                                        │
│   11                                                                                             │
│                                                                                                  │
│ /puffertank/pufferlib/pufferlib/pufferl.py:1332 in main                                          │
│                                                                                                  │
│   1329 │   mode = sys.argv.pop(1)                                                                │
│   1330 │   env_name = sys.argv.pop(1)                                                            │
│   1331 │   if mode == 'train':                                                                   │
│ ❱ 1332 │   │   train(env_name=env_name)                                                          │
│   1333 │   elif mode == 'eval':                                                                  │
│   1334 │   │   eval(env_name=env_name)                                                           │
│   1335 │   elif mode == 'sweep':                                                                 │
│                                                                                                  │
│ /puffertank/pufferlib/pufferlib/pufferl.py:924 in train                                          │
│                                                                                                  │
│    921 │   │   torch.cuda.set_device(local_rank)                                                 │
│    922 │   │   os.environ["CUDA_VISIBLE_DEVICES"] = str(local_rank)                              │
│    923 │                                                                                         │
│ ❱  924 │   vecenv = vecenv or load_env(env_name, args)                                           │
│    925 │   policy = policy or load_policy(args, vecenv, env_name)                                │
│    926 │                                                                                         │
│    927 │   if 'LOCAL_RANK' in os.environ:                                                        │
│                                                                                                  │
│ /puffertank/pufferlib/pufferlib/pufferl.py:1177 in load_env                                      │
│                                                                                                  │
│   1174 │   module_name = 'pufferlib.ocean' if package == 'ocean' else f'pufferlib.environments.  │
│   1175 │   env_module = importlib.import_module(module_name)                                     │
│   1176 │   make_env = env_module.env_creator(env_name)                                           │
│ ❱ 1177 │   return pufferlib.vector.make(make_env, env_kwargs=args['env'], **args['vec'])         │
│   1178                                                                                           │
│   1179 def load_policy(args, vecenv, env_name=''):                                               │
│   1180 │   package = args['package']                                                             │
│                                                                                                  │
│ /puffertank/pufferlib/pufferlib/vector.py:646 in make                                            │
│                                                                                                  │
│   643 │   │   │   kwargs['num_workers'] = num_envs                                               │
│   644 │   │                                                                                      │
│   645 │   │   # TODO: None?                                                                      │
│ ❱ 646 │   │   envs_per_worker = num_envs / kwargs['num_workers']                                 │
│   647 │   │   if envs_per_worker != int(envs_per_worker):                                        │
│   648 │   │   │   raise pufferlib.APIUsageError('num_envs must be divisible by num_workers')     │
│   649                                                                                            │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ZeroDivisionError: division by zero

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed it to auto but then it defaults to 128 (num_envs) I think which is even worse

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. Changed it to use auto detection based on CPU cores instead of hardcoding.

Now auto sets num_workers to min(cpu_cores, num_envs) which is safe and performant. Also updated vector.py to handle 'auto' properly instead of defaulting to num_envs.

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

Successfully merging this pull request may close these issues.

Atari is a funny (broken) environment

2 participants