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
[Bug] RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument mat1 in method wrapper_addmm) #21921
Comments
@alexvaca0, |
same problem here, any solution yet? |
I'm not sure yet, but I think the reasons I get this error is because my (custom) environment use a multi dimensional observations space:
Moving to I have modify my environment accordingly and in I suspect that if I test it on I hope this may help You |
@easysoft2k15 you are partially right, in my experiments: Ray does not work with multi dimentional observation spaces, unless you use "conv_filters", as per documentaiton here: |
thanks! flattening the observation fixed the problem |
Yeah, it seems if you have any observations like |
This problem was solved for me by pip install ray[default,tune,rllib,serve]==1.9.2 Hope it helps! |
This works, it seems like the built-in |
This is a real bug in The problem in |
Not using the GPU won't work for me unfortunately (need it for speed)... is there any fix for this which includes being able to use the GPU? |
Search before asking
Ray Component
Ray Tune, RLlib
What happened + What you expected to happen
When trying a RLLib experiment following these guidelines: https://www.tensortrade.org/en/latest/examples/train_and_evaluate_using_ray.html
with this config:
tune.run( run_or_experiment="PPO", # We'll be using the builtin PPO agent in RLLib name="MyExperiment1", metric='episode_reward_mean', mode='max', # resources_per_trial= {"cpu": 8, "gpu": 1}, stop={ "training_iteration": 100 # Let's do 5 steps for each hyperparameter combination }, config={ "env": "MyTrainingEnv", "env_config": config_train, # The dictionary we built before "log_level": "WARNING", "framework": "torch", "_fake_gpus": False, "ignore_worker_failures": True, "num_workers": 1, # One worker per agent. You can increase this but it will run fewer parallel trainings. "num_envs_per_worker": 1, "num_gpus": 1, # I yet have to understand if using a GPU is worth it, for our purposes, but I think it's not. This way you can train on a non-gpu enabled system. "clip_rewards": True, "lr": LEARNING_RATE, # Hyperparameter grid search defined above "gamma": GAMMA, # This can have a big impact on the result and needs to be properly tuned (range is 0 to 1) "lambda": LAMBDA, "observation_filter": "MeanStdFilter", "model": { "fcnet_hiddens": FC_SIZE, # Hyperparameter grid search defined above #"use_attention": True, #"attention_use_n_prev_actions": 120, #"attention_use_n_prev_rewards": 120 }, "sgd_minibatch_size": MINIBATCH_SIZE, # Hyperparameter grid search defined above "evaluation_interval": 1, # Run evaluation on every iteration "evaluation_config": { "env_config": config_eval, # The dictionary we built before (only the overriding keys to use in evaluation) "explore": False, # We don't want to explore during evaluation. All actions have to be repeatable. }, }, num_samples=1, # Have one sample for each hyperparameter combination. You can have more to average out randomness. keep_checkpoints_num=3, # Keep the last 2 checkpoints checkpoint_freq=1, # Do a checkpoint on each iteration (slower but you can pick more finely the checkpoint to use later) local_dir=r"D:\ray_results" )
I encountered the following error:
I would expect tensors to be placed on the same device.
Versions / Dependencies
OS: Windows 10
Ray: 2.0.0.dev0
Python: 3.8
Torch: 1.10.1
CUDA: 11.4
Reproduction script
https://www.tensortrade.org/en/latest/examples/train_and_evaluate_using_ray.html
Anything else
No response
Are you willing to submit a PR?
The text was updated successfully, but these errors were encountered: