Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pufferlib/config/atari.ini
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ rnn_name = Recurrent

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

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
Copy Markdown

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
Copy Markdown
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.

batch_size = 64

[train]
Expand Down
2 changes: 1 addition & 1 deletion pufferlib/environments/atari/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def make(name, obs_type='grayscale', frameskip=4,
repeat_action_probability=0.0, render_mode='rgb_array',
buf=None, seed=0):
'''Atari creation function'''
pufferlib.environments.try_import('ale_py', 'AtariEnv')
pufferlib.environments.try_import('ale_py')

ale_render_mode = render_mode
if render_mode == 'human':
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ avalon = [
atari = [
'gymnasium[accept-rom-license]==0.29.1',
'opencv-python==3.4.17.63',
'ale_py==0.9.0',
'ale_py==0.10.1',
]

box2d = [
Expand Down