forked from espnet/espnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install_warp-ctc.sh
executable file
·108 lines (86 loc) · 2.18 KB
/
install_warp-ctc.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env bash
set -euo pipefail
MAKE=make
if [ $# != 0 ]; then
echo "Usage: $0"
exit 1;
fi
torch_17_plus=$(python3 <<EOF
from distutils.version import LooseVersion as V
import torch
if V(torch.__version__) >= V("1.7"):
print("true")
else:
print("false")
EOF
)
torch_11_plus=$(python3 <<EOF
from distutils.version import LooseVersion as V
import torch
if V(torch.__version__) >= V("1.1"):
print("true")
else:
print("false")
EOF
)
torch_10_plus=$(python3 <<EOF
from distutils.version import LooseVersion as V
import torch
if V(torch.__version__) >= V("1.0"):
print("true")
else:
print("false")
EOF
)
torch_version=$(python3 <<EOF
import torch
version = torch.__version__.split(".")
print(version[0] + version[1])
EOF
)
cuda_version=$(python3 <<EOF
import torch
if torch.cuda.is_available():
version=torch.version.cuda.split(".")
# 10.1.aa -> 101
print(version[0] + version[1])
else:
print("")
EOF
)
echo "cuda_version=${cuda_version}"
if "${torch_17_plus}"; then
echo "[WARNING] warp-ctc is not prepared for pytorch>=1.7.0 now"
elif "${torch_11_plus}"; then
warpctc_version=0.2.2
release_page_url=https://github.com/espnet/warp-ctc/releases/tag/v${warpctc_version}
if [ -z "${cuda_version}" ]; then
python3 -m pip install warpctc-pytorch==${warpctc_version}+torch"${torch_version}".cpu -f ${release_page_url}
else
python3 -m pip install warpctc-pytorch==${warpctc_version}+torch"${torch_version}".cuda"${cuda_version}" -f ${release_page_url}
fi
elif "${torch_10_plus}"; then
if [ -z "${cuda_version}" ]; then
python3 -m pip install warpctc-pytorch10-cpu
else
python3 -m pip install warpctc-pytorch10-cuda"${cuda_version}"
fi
else
rm -rf warp-ctc
git clone https://github.com/espnet/warp-ctc.git
(
set -euo pipefail
cd warp-ctc
git checkout -b pytorch-0.4 remotes/origin/pytorch-0.4
mkdir build
(
set -euo pipefail
cd build && cmake .. && ${MAKE}
)
python3 -m pip install cffi
(
set -euo pipefail
cd pytorch_binding && python3 -m pip install -e .
)
)
fi