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.
In the original
wavemix/__init__.py
, some layers are put on 'cuda:0' by default, and this cannot be changed. This behavior is undesirable since upon initialization, some weights are on 'cuda:0' and the rest are on 'cpu', until model.to('cuda:0') is called.Additionally, on servers with more than one gpu, if gpu 0 is in use, wavemix models cannot be used. There is another bug which prevents conveniently putting the whole model on say 'cuda:4': the
DWTForward
layers are defined outside theLevelXWaveblock
s and since they are not "children" of the waveblocks, whenwaveblock.to('cuda:4')
is called, the xf1, xf2, xf3, xf4 are still on 'cuda:0', causing device mismatch errors.This patch fixes these issues by changing the default device argument in the defined functions to 'cpu', which makes all weights initialized on 'cpu' at first, and defines xf1, xf2, xf3, xf4 inside their respective waveblocks, which allows waveblock.to('cuda:N') to work as intended.