-
Notifications
You must be signed in to change notification settings - Fork 256
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
Ensure safe_to_tensor moves tensors to the specified device. #831
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #831 +/- ##
==========================================
+ Coverage 95.69% 95.76% +0.07%
==========================================
Files 102 102
Lines 9645 9640 -5
==========================================
+ Hits 9230 9232 +2
+ Misses 415 408 -7 ☔ View full report in Codecov by Sentry. |
563bccf
to
7474c6c
Compare
02d1c17
to
7e618b0
Compare
I think the coverage warning in this one is spurious. Can you merge this @AdamGleave ? |
Looks like the issue is that |
Hello, what's the state of this PR? |
In the latest version I downloaded, this problem is still not solved. |
9945450
to
cc61abc
Compare
./ci/build_and_activate_venv.sh ~/venv python3.9 fails because python3.9 is not installed.
The error message: Warning, treated as error: ********************************************************************** File "algorithms/dagger.rst", line 45, in default Failed example: import tempfile import numpy as np import gymnasium as gym from stable_baselines3.common.evaluation import evaluate_policy from imitation.algorithms import bc from imitation.algorithms.dagger import SimpleDAggerTrainer from imitation.policies.serialize import load_policy from imitation.util.util import make_vec_env rng = np.random.default_rng(0) env = make_vec_env( "seals:seals/CartPole-v0", rng=rng, ) expert = load_policy( "ppo-huggingface", organization="HumanCompatibleAI", env_name="seals-CartPole-v0", venv=env, ) bc_trainer = bc.BC( observation_space=env.observation_space, action_space=env.action_space, rng=rng, ) with tempfile.TemporaryDirectory(prefix="dagger_example_") as tmpdir: print(tmpdir) dagger_trainer = SimpleDAggerTrainer( venv=env, scratch_dir=tmpdir, expert_policy=expert, bc_trainer=bc_trainer, rng=rng, ) dagger_trainer.train(8_000) reward, _ = evaluate_policy(dagger_trainer.policy, env, 10) print("Reward:", reward) Exception raised: Traceback (most recent call last): File "/usr/lib/python3.8/doctest.py", line 1336, in __run exec(compile(example.source, filename, "single", File "<doctest default[0]>", line 38, in <module> dagger_trainer.train(8_000) File "/venv/lib/python3.8/site-packages/imitation/algorithms/dagger.py", line 669, in train trajectories = rollout.generate_trajectories( File "/venv/lib/python3.8/site-packages/imitation/data/rollout.py", line 447, in generate_trajectories obs, rews, dones, infos = venv.step(acts) File "/venv/lib/python3.8/site-packages/stable_baselines3/common/vec_env/base_vec_env.py", line 206, in step return self.step_wait() File "/venv/lib/python3.8/site-packages/imitation/algorithms/dagger.py", line 285, in step_wait _save_dagger_demo(traj, traj_index, self.save_dir, self.rng) File "/venv/lib/python3.8/site-packages/imitation/algorithms/dagger.py", line 147, in _save_dagger_demo serialize.save(npz_path, [trajectory]) File "/venv/lib/python3.8/site-packages/imitation/data/serialize.py", line 23, in save huggingface_utils.trajectories_to_dataset(trajectories).save_to_disk(p) File "/venv/lib/python3.8/site-packages/datasets/arrow_dataset.py", line 1470, in save_to_disk fs, _ = url_to_fs(dataset_path, **(storage_options or {})) File "/venv/lib/python3.8/site-packages/fsspec/core.py", line 383, in url_to_fs chain = _un_chain(url, kwargs) File "/venv/lib/python3.8/site-packages/fsspec/core.py", line 323, in _un_chain if "::" in path TypeError: argument of type 'PosixPath' is not iterable
This reverts commit b765aff.
be007c6
to
ca3f001
Compare
I can take a look at merging this later this week, but there a bunch of new CI failures that I would need to resolve due to various versions changing in CI or packages over the past year that this PR has sat dormant. In general no one is actively maintaining this repository now so if there are issues you may need to fork the repo and handle it yourself. |
b099761
to
49b3e70
Compare
d79080b
to
f64b3fc
Compare
Made a bunch of misc changes to fix CI, it would've been better for me to make them a separate PR but I'm not sure I would've been able to get a code owner to review the PR. I'll just list the changes in this comment.
fixed in 30f9048 by casting the
I couldn't figure out how to properly fix this but I happened to notice that this didn't happen in newer Python versions so I just changed the windows CI tests to use python 3.9 instead of 3.8.
I ignored the torch ones in f64b3fc and fixed the remaining ones in 5820cfe. |
This PR fixes a bug in the
safe_to_tensor
utility: previously it did not move tensors to a new device according to thedevice
kwarg which caused issues when there is more than one device available.The bug went unnoticed for a long while since our circleCI runners do not have GPUs enabled.
Thanks to @tomtseng for drafting a fix for this in #828