Spaces:
Sleeping
Sleeping
Erva Ulusoy
commited on
Commit
·
589e75e
1
Parent(s):
23f3d8f
fix env building error
Browse files- packages.txt +1 -0
- postBuild +69 -0
- runtime.txt +1 -0
packages.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
patchelf
|
postBuild
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
set -euo pipefail
|
| 3 |
+
|
| 4 |
+
# Some hardened environments (e.g., newer glibc / gVisor) refuse to dlopen()
|
| 5 |
+
# shared objects that request an executable stack. Certain PyTorch builds can
|
| 6 |
+
# ship with this flag set on libtorch_cpu.so. Clearing it fixes torch import.
|
| 7 |
+
|
| 8 |
+
python - <<'PY'
|
| 9 |
+
import os, site, glob
|
| 10 |
+
|
| 11 |
+
paths = []
|
| 12 |
+
for fn in (getattr(site, "getsitepackages", None), getattr(site, "getusersitepackages", None)):
|
| 13 |
+
if fn is None:
|
| 14 |
+
continue
|
| 15 |
+
try:
|
| 16 |
+
p = fn()
|
| 17 |
+
if isinstance(p, str):
|
| 18 |
+
paths.append(p)
|
| 19 |
+
else:
|
| 20 |
+
paths.extend(list(p))
|
| 21 |
+
except Exception:
|
| 22 |
+
pass
|
| 23 |
+
|
| 24 |
+
targets = []
|
| 25 |
+
for p in paths:
|
| 26 |
+
targets += glob.glob(os.path.join(p, "torch", "lib", "libtorch_cpu.so"))
|
| 27 |
+
targets += glob.glob(os.path.join(p, "torch", "lib", "libtorch_python.so"))
|
| 28 |
+
|
| 29 |
+
print("\n".join(sorted(set(targets))))
|
| 30 |
+
PY
|
| 31 |
+
|
| 32 |
+
TARGETS="$(python - <<'PY'
|
| 33 |
+
import os, site, glob
|
| 34 |
+
|
| 35 |
+
paths = []
|
| 36 |
+
for fn in (getattr(site, "getsitepackages", None), getattr(site, "getusersitepackages", None)):
|
| 37 |
+
if fn is None:
|
| 38 |
+
continue
|
| 39 |
+
try:
|
| 40 |
+
p = fn()
|
| 41 |
+
if isinstance(p, str):
|
| 42 |
+
paths.append(p)
|
| 43 |
+
else:
|
| 44 |
+
paths.extend(list(p))
|
| 45 |
+
except Exception:
|
| 46 |
+
pass
|
| 47 |
+
|
| 48 |
+
targets = []
|
| 49 |
+
for p in paths:
|
| 50 |
+
targets += glob.glob(os.path.join(p, "torch", "lib", "libtorch_cpu.so"))
|
| 51 |
+
targets += glob.glob(os.path.join(p, "torch", "lib", "libtorch_python.so"))
|
| 52 |
+
|
| 53 |
+
print(" ".join(sorted(set(targets))))
|
| 54 |
+
PY
|
| 55 |
+
)"
|
| 56 |
+
|
| 57 |
+
if [[ -z "${TARGETS}" ]]; then
|
| 58 |
+
echo "postBuild: no torch .so targets found yet (torch may not be installed)."
|
| 59 |
+
exit 0
|
| 60 |
+
fi
|
| 61 |
+
|
| 62 |
+
for so in ${TARGETS}; do
|
| 63 |
+
if [[ -f "${so}" ]]; then
|
| 64 |
+
echo "postBuild: clearing execstack on ${so}"
|
| 65 |
+
# If it fails (e.g. already clear), continue.
|
| 66 |
+
patchelf --clear-execstack "${so}" || true
|
| 67 |
+
fi
|
| 68 |
+
done
|
| 69 |
+
|
runtime.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
python-3.8
|