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
73255170
Unverified
Commit
73255170
authored
May 09, 2023
by
Philip Meier
Committed by
GitHub
May 09, 2023
Browse files
remove obsolete pre Pyhton3.8 compat (#7559)
parent
2caa84fa
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
2 additions
and
25 deletions
+2
-25
torchvision/_internally_replaced_utils.py
torchvision/_internally_replaced_utils.py
+1
-9
torchvision/extension.py
torchvision/extension.py
+1
-16
No files found.
torchvision/_internally_replaced_utils.py
View file @
73255170
...
...
@@ -28,7 +28,6 @@ def _get_extension_path(lib_name):
if
os
.
name
==
"nt"
:
# Register the main torchvision library location on the default DLL path
import
ctypes
import
sys
kernel32
=
ctypes
.
WinDLL
(
"kernel32.dll"
,
use_last_error
=
True
)
with_load_library_flags
=
hasattr
(
kernel32
,
"AddDllDirectory"
)
...
...
@@ -37,14 +36,7 @@ def _get_extension_path(lib_name):
if
with_load_library_flags
:
kernel32
.
AddDllDirectory
.
restype
=
ctypes
.
c_void_p
if
sys
.
version_info
>=
(
3
,
8
):
os
.
add_dll_directory
(
lib_dir
)
elif
with_load_library_flags
:
res
=
kernel32
.
AddDllDirectory
(
lib_dir
)
if
res
is
None
:
err
=
ctypes
.
WinError
(
ctypes
.
get_last_error
())
err
.
strerror
+=
f
' Error adding "
{
lib_dir
}
" to the DLL directories.'
raise
err
os
.
add_dll_directory
(
lib_dir
)
kernel32
.
SetErrorMode
(
prev_error_mode
)
...
...
torchvision/extension.py
View file @
73255170
import
ctypes
import
os
import
sys
from
warnings
import
warn
import
torch
...
...
@@ -22,7 +20,7 @@ try:
# conda environment/bin path is configured Please take a look:
# https://stackoverflow.com/questions/59330863/cant-import-dll-module-in-python
# Please note: if some path can't be added using add_dll_directory we simply ignore this path
if
os
.
name
==
"nt"
and
sys
.
version_info
>=
(
3
,
8
)
and
sys
.
version_info
<
(
3
,
9
):
if
os
.
name
==
"nt"
and
sys
.
version_info
<
(
3
,
9
):
env_path
=
os
.
environ
[
"PATH"
]
path_arr
=
env_path
.
split
(
";"
)
for
path
in
path_arr
:
...
...
@@ -88,19 +86,6 @@ def _check_cuda_version():
def
_load_library
(
lib_name
):
lib_path
=
_get_extension_path
(
lib_name
)
# On Windows Python-3.8+ has `os.add_dll_directory` call,
# which is called from _get_extension_path to configure dll search path
# Condition below adds a workaround for older versions by
# explicitly calling `LoadLibraryExW` with the following flags:
# - LOAD_LIBRARY_SEARCH_DEFAULT_DIRS (0x1000)
# - LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR (0x100)
if
os
.
name
==
"nt"
and
sys
.
version_info
<
(
3
,
8
):
_kernel32
=
ctypes
.
WinDLL
(
"kernel32.dll"
,
use_last_error
=
True
)
if
hasattr
(
_kernel32
,
"LoadLibraryExW"
):
_kernel32
.
LoadLibraryExW
(
lib_path
,
None
,
0x00001100
)
else
:
warn
(
"LoadLibraryExW is missing in kernel32.dll"
)
torch
.
ops
.
load_library
(
lib_path
)
...
...
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