Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
b3cb86f2
Commit
b3cb86f2
authored
May 22, 2019
by
Soumith Chintala
Browse files
version check against PyTorch's CUDA version
parent
c7a4ca99
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
0 deletions
+38
-0
setup.py
setup.py
+3
-0
torchvision/__init__.py
torchvision/__init__.py
+28
-0
torchvision/csrc/vision.cpp
torchvision/csrc/vision.cpp
+7
-0
No files found.
setup.py
View file @
b3cb86f2
...
...
@@ -56,6 +56,9 @@ def write_version_file():
with
open
(
version_path
,
'w'
)
as
f
:
f
.
write
(
"__version__ = '{}'
\n
"
.
format
(
version
))
f
.
write
(
"git_version = {}
\n
"
.
format
(
repr
(
sha
)))
f
.
write
(
"from torchvision import _C
\n
"
)
f
.
write
(
"if hasattr(_C, 'CUDA_VERSION'):
\n
"
)
f
.
write
(
" cuda = _C.CUDA_VERSION
\n
"
)
write_version_file
()
...
...
torchvision/__init__.py
View file @
b3cb86f2
...
...
@@ -33,3 +33,31 @@ def get_image_backend():
Gets the name of the package used to load images
"""
return
_image_backend
def
_check_cuda_matches
():
"""
Make sure that CUDA versions match between the pytorch install and torchvision install
"""
import
torch
from
torchvision
import
_C
if
hasattr
(
_C
,
"CUDA_VERSION"
)
and
torch
.
version
.
cuda
is
not
None
:
tv_version
=
str
(
_C
.
CUDA_VERSION
)
if
int
(
tv_version
)
<
10000
:
tv_major
=
int
(
tv_version
[
0
])
tv_minor
=
int
(
tv_version
[
2
])
else
:
tv_major
=
int
(
tv_version
[
0
:
2
])
tv_minor
=
int
(
tv_version
[
3
])
t_version
=
torch
.
version
.
cuda
t_version
=
t_version
.
split
(
'.'
)
t_major
=
int
(
t_version
[
0
])
t_minor
=
int
(
t_version
[
1
])
if
t_major
!=
tv_major
or
t_minor
!=
tv_minor
:
raise
RuntimeError
(
"Detected that PyTorch and torchvision were compiled with different CUDA versions. "
"PyTorch has CUDA Version={}.{} and torchvision has CUDA Version={}.{}. "
"Please reinstall the torchvision that matches your PyTorch install."
.
format
(
t_major
,
t_minor
,
tv_major
,
tv_minor
))
_check_cuda_matches
()
torchvision/csrc/vision.cpp
View file @
b3cb86f2
...
...
@@ -2,10 +2,17 @@
#include "ROIPool.h"
#include "nms.h"
#ifdef WITH_CUDA
#include <cuda.h>
#endif
PYBIND11_MODULE
(
TORCH_EXTENSION_NAME
,
m
)
{
m
.
def
(
"nms"
,
&
nms
,
"non-maximum suppression"
);
m
.
def
(
"roi_align_forward"
,
&
ROIAlign_forward
,
"ROIAlign_forward"
);
m
.
def
(
"roi_align_backward"
,
&
ROIAlign_backward
,
"ROIAlign_backward"
);
m
.
def
(
"roi_pool_forward"
,
&
ROIPool_forward
,
"ROIPool_forward"
);
m
.
def
(
"roi_pool_backward"
,
&
ROIPool_backward
,
"ROIPool_backward"
);
#ifdef WITH_CUDA
m
.
attr
(
"CUDA_VERSION"
)
=
CUDA_VERSION
;
#endif
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment