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
c9900cbf
Commit
c9900cbf
authored
Jun 07, 2023
by
panning
Browse files
add dcu_version
parent
d36dd763
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
3 deletions
+36
-3
setup.py
setup.py
+31
-3
torchvision/__init__.py
torchvision/__init__.py
+5
-0
No files found.
setup.py
View file @
c9900cbf
...
@@ -32,6 +32,19 @@ with open(version_txt) as f:
...
@@ -32,6 +32,19 @@ with open(version_txt) as f:
sha
=
"Unknown"
sha
=
"Unknown"
package_name
=
"torchvision"
package_name
=
"torchvision"
dcu_version
=
version
def
get_abi
():
try
:
command
=
"echo '#include <string>' | gcc -x c++ -E -dM - | fgrep _GLIBCXX_USE_CXX11_ABI"
result
=
subprocess
.
run
(
command
,
shell
=
True
,
capture_output
=
True
,
text
=
True
)
output
=
result
.
stdout
.
strip
()
abi
=
"abi"
+
output
.
split
(
" "
)[
-
1
]
return
abi
except
Exception
:
return
'abiUnknown'
try
:
try
:
sha
=
subprocess
.
check_output
([
"git"
,
"rev-parse"
,
"HEAD"
],
cwd
=
cwd
).
decode
(
"ascii"
).
strip
()
sha
=
subprocess
.
check_output
([
"git"
,
"rev-parse"
,
"HEAD"
],
cwd
=
cwd
).
decode
(
"ascii"
).
strip
()
except
Exception
:
except
Exception
:
...
@@ -39,14 +52,29 @@ except Exception:
...
@@ -39,14 +52,29 @@ except Exception:
if
os
.
getenv
(
"BUILD_VERSION"
):
if
os
.
getenv
(
"BUILD_VERSION"
):
version
=
os
.
getenv
(
"BUILD_VERSION"
)
version
=
os
.
getenv
(
"BUILD_VERSION"
)
elif
sha
!=
"Unknown"
:
#elif sha != "Unknown":
version
+=
"+"
+
sha
[:
7
]
# version += "+" + sha[:7]
if
sha
!=
'Unknown'
:
dcu_version
+=
'+git'
+
sha
[:
7
]
dcu_version
+=
"."
+
get_abi
()
if
os
.
getenv
(
"ROCM_PATH"
):
rocm_path
=
os
.
getenv
(
'ROCM_PATH'
,
""
)
rocm_version_path
=
os
.
path
.
join
(
rocm_path
,
'.info'
,
"version-dev"
)
with
open
(
rocm_version_path
,
'r'
,
encoding
=
'utf-8'
)
as
file
:
lines
=
file
.
readlines
()
rocm_version
=
lines
[
0
][:
-
2
].
replace
(
"."
,
""
)
dcu_version
+=
".dtk"
+
rocm_version
# torch version
dcu_version
+=
".torch"
+
torch
.
__version__
[:
-
2
]
def
write_version_file
():
def
write_version_file
():
version_path
=
os
.
path
.
join
(
cwd
,
"torchvision"
,
"version.py"
)
version_path
=
os
.
path
.
join
(
cwd
,
"torchvision"
,
"version.py"
)
with
open
(
version_path
,
"w"
)
as
f
:
with
open
(
version_path
,
"w"
)
as
f
:
f
.
write
(
f
"__version__ = '
{
version
}
'
\n
"
)
f
.
write
(
f
"__version__ = '
{
version
}
'
\n
"
)
f
.
write
(
"__dcu_version__ = '{}'
\n
"
.
format
(
dcu_version
))
f
.
write
(
f
"git_version =
{
repr
(
sha
)
}
\n
"
)
f
.
write
(
f
"git_version =
{
repr
(
sha
)
}
\n
"
)
f
.
write
(
"from torchvision.extension import _check_cuda_version
\n
"
)
f
.
write
(
"from torchvision.extension import _check_cuda_version
\n
"
)
f
.
write
(
"if _check_cuda_version() > 0:
\n
"
)
f
.
write
(
"if _check_cuda_version() > 0:
\n
"
)
...
@@ -530,7 +558,7 @@ if __name__ == "__main__":
...
@@ -530,7 +558,7 @@ if __name__ == "__main__":
setup
(
setup
(
# Metadata
# Metadata
name
=
package_name
,
name
=
package_name
,
version
=
version
,
version
=
dcu_
version
,
author
=
"PyTorch Core Team"
,
author
=
"PyTorch Core Team"
,
author_email
=
"soumith@pytorch.org"
,
author_email
=
"soumith@pytorch.org"
,
url
=
"https://github.com/pytorch/vision"
,
url
=
"https://github.com/pytorch/vision"
,
...
...
torchvision/__init__.py
View file @
c9900cbf
...
@@ -11,6 +11,11 @@ try:
...
@@ -11,6 +11,11 @@ try:
except
ImportError
:
except
ImportError
:
pass
pass
try
:
from
.version
import
__dcu_version__
# noqa: F401
except
ImportError
:
pass
# Check if torchvision is being imported within the root folder
# Check if torchvision is being imported within the root folder
if
not
_HAS_OPS
and
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
==
os
.
path
.
join
(
if
not
_HAS_OPS
and
os
.
path
.
dirname
(
os
.
path
.
realpath
(
__file__
))
==
os
.
path
.
join
(
os
.
path
.
realpath
(
os
.
getcwd
()),
"torchvision"
os
.
path
.
realpath
(
os
.
getcwd
()),
"torchvision"
...
...
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