Closed minhlong94 closed 3 years ago
The problem is in creating a new layer inside forward
function. This part:
self.last_layer = nn.Sequential(nn.Linear(cat.shape[1], self.features_dim*2), nn.Tanh(),
nn.Linear(self.features_dim*2, self.features_dim), nn.Tanh())
You should create all layers in the __init__
function, otherwise these layers are not included in the training and you will be re-creating layers on every network call. If you really must do this, then you need to move these layers to model's device (see PyTorch docs).
Oh I see, that is indeed a serious mistake. I will close the issue accordingly then.
Important Note: We do not do technical support, nor consulting and don't answer personal questions per email. Please post your question on the RL Discord, Reddit or Stack Overflow in that case.
If your issue is related to a custom gym environment, please use the custom gym env template.
🐛 Bug
Runtime error: device (CUDA) mismatch when using
MultiInputPolicy
on version1.1.0a11
with custom environment and features extractor, on DQN.To Reproduce
Since I am not allowed to publish the full code yet, I will try my best to describe the steps to reproduce. These names are replaced with
XXX
(and I may miss some).Here is the observation and action space:
And this is the Features Extractor:
And I call the training like usual:
THE PROBLEM: if the device is set to
cuda
, it throws the following trace error, while if it iscpu
it works perfectly fine.The error even happens on Kaggle kernel.
System Info
Describe the characteristic of your environment:
pip
, and on Kaggle kernelstable-baselines3==1.1.0a11
Checklist