Open
Conversation
Zentrik
reviewed
Dec 28, 2025
pufferlib/config/atari.ini
Outdated
| [vec] | ||
| num_envs = 128 | ||
| num_workers = 16 | ||
| num_workers = 0 |
There was a problem hiding this comment.
╭─────────────────────────────── 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
There was a problem hiding this comment.
I changed it to auto but then it defaults to 128 (num_envs) I think which is even worse
Author
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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