Skip to content
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

RandomPlanckianJitter incorrect values on gpu other than 0 #2791

Closed
Modexus opened this issue Feb 8, 2024 · 3 comments · Fixed by #2792
Closed

RandomPlanckianJitter incorrect values on gpu other than 0 #2791

Modexus opened this issue Feb 8, 2024 · 3 comments · Fixed by #2792
Labels
help wanted Extra attention is needed

Comments

@Modexus
Copy link
Contributor

Modexus commented Feb 8, 2024

Describe the bug

RandomPlanckianJitter has a bug from get_planckian_coeffs(mode) that always puts self.pl on gpu 0.
self.pl is not registered in the module and does not get moved to the correct gpu.
Moving self.pl from gpu0 to another gpu directly results in incorrect values.

Reproduction steps

augmentation = kornia.augmentation.RandomPlanckianJitter(p=1.0)
pl = augmentation.pl.clone()
augmentation(torch.rand(3, 3, 3).to("cuda:0"))
print((pl.cpu() == augmentation.pl.cpu()).all())
augmentation(torch.rand(3, 3, 3).to("cuda:1"))
print((pl.cpu() == augmentation.pl.cpu()).all())

-
tensor(True)
tensor(False)

Expected behavior

Either self.pl should be registered so it moves when the module moves to the correct gpu or self.pl should remain on cpu and get moved in the call.

Environment

This does not occur on all machines.
Happens on this machine with 3070s but not on one with A5000.

PyTorch version: 2.2.0+cu121
Is debug build: False
CUDA used to build PyTorch: 12.1
ROCM used to build PyTorch: N/A

OS: Fedora Linux 37 (Thirty Seven) (x86_64)
GCC version: (GCC) 12.3.1 20230508 (Red Hat 12.3.1-1)
Clang version: Could not collect
CMake version: version 3.27.7
Libc version: glibc-2.36

Python version: 3.11.6 (main, Oct  3 2023, 00:00:00) [GCC 12.3.1 20230508 (Red Hat 12.3.1-1)] (64-bit runtime)
Python platform: Linux-6.5.12-100.fc37.x86_64-x86_64-with-glibc2.36
Is CUDA available: True
CUDA runtime version: 12.2.140
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: 
GPU 0: NVIDIA GeForce RTX 3070
GPU 1: NVIDIA GeForce RTX 3070
GPU 2: NVIDIA GeForce RTX 3070
GPU 3: NVIDIA GeForce RTX 3070

Nvidia driver version: 545.29.06
cuDNN version: Probably one of the following:
/usr/lib64/libcudnn.so.8.9.7
/usr/lib64/libcudnn_adv_infer.so.8.9.7
/usr/lib64/libcudnn_adv_train.so.8.9.7
/usr/lib64/libcudnn_cnn_infer.so.8.9.7
/usr/lib64/libcudnn_cnn_train.so.8.9.7
/usr/lib64/libcudnn_ops_infer.so.8.9.7
/usr/lib64/libcudnn_ops_train.so.8.9.7
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                       x86_64
CPU op-mode(s):                     32-bit, 64-bit
Address sizes:                      43 bits physical, 48 bits virtual
Byte Order:                         Little Endian
CPU(s):                             48
On-line CPU(s) list:                0-47
Vendor ID:                          AuthenticAMD
Model name:                         AMD Ryzen Threadripper 3960X 24-Core Processor
CPU family:                         23
Model:                              49
Thread(s) per core:                 2
Core(s) per socket:                 24
Socket(s):                          1
Stepping:                           0
Frequency boost:                    enabled
CPU(s) scaling MHz:                 81%
CPU max MHz:                        3800.0000
CPU min MHz:                        2200.0000
BogoMIPS:                           7599.98
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd amd_ppin arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip rdpid overflow_recov succor smca sev sev_es
Virtualization:                     AMD-V
L1d cache:                          768 KiB (24 instances)
L1i cache:                          768 KiB (24 instances)
L2 cache:                           12 MiB (24 instances)
L3 cache:                           128 MiB (8 instances)
NUMA node(s):                       1
NUMA node0 CPU(s):                  0-47
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Not affected
Vulnerability Retbleed:             Mitigation; untrained return thunk; SMT enabled with STIBP protection
Vulnerability Spec rstack overflow: Mitigation; Safe RET
Vulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:           Mitigation; Retpolines, IBPB conditional, STIBP always-on, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected

Versions of relevant libraries:
[pip3] numpy==1.26.4
[pip3] torch==2.2.0
[pip3] triton==2.2.0
[conda] numpy                     1.24.2                   pypi_0    pypi
[conda] pytorch-triton            2.1.0+7d1a95b046          pypi_0    pypi
[conda] torch-tb-profiler         0.4.1                    pypi_0    pypi
[conda] torchvision               0.16.0.dev20230508+cu118          pypi_0    pypi

Additional context

No response

@Modexus Modexus added the help wanted Extra attention is needed label Feb 8, 2024
@edgarriba
Copy link
Member

@Modexus could you send a PR with the fix ?

@Modexus
Copy link
Contributor Author

Modexus commented Feb 8, 2024

I have created a PR but am not quite sure if registering it as a buffer is how it is normally done in kornia.
At least this fixes the issue when the augmentation is moved to the same gpu.

@edgarriba
Copy link
Member

edgarriba commented Feb 9, 2024

Thank, i think as buffer is reasonable here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants