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
dgl
Commits
40c968b7
Unverified
Commit
40c968b7
authored
Feb 14, 2023
by
Hongzhi (Steve), Chen
Committed by
GitHub
Feb 14, 2023
Browse files
fix (#5293)
Co-authored-by:
Steve
<
ubuntu@ip-172-31-34-29.ap-northeast-1.compute.internal
>
parent
fb8677b4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
26 deletions
+26
-26
script/create_dev_conda_env.sh
script/create_dev_conda_env.sh
+26
-26
No files found.
script/create_dev_conda_env.sh
View file @
40c968b7
#!/bin/bash
#!/bin/bash
CUDA_VERSIONS
=
"10.2,11.3,11.6,11.7"
readonly
CUDA_VERSIONS
=
"10.2,11.3,11.6,11.7"
TORCH_VERSION
=
"1.12.0"
readonly
TORCH_VERSION
=
"1.12.0"
usage
()
{
usage
()
{
cat
<<
EOF
cat
<<
EOF
...
@@ -10,21 +10,21 @@ examples:
...
@@ -10,21 +10,21 @@ examples:
bash
$0
-c
bash
$0
-c
bash
$0
-g 11.7
bash
$0
-g 11.7
Create
d
a developement environment for DGL developers.
Create a developement environment for DGL developers.
OPTIONS:
OPTIONS:
-h Show this message.
-h Show this message.
-c Create dev environment in CPU mode.
-c Create dev environment in CPU mode.
-g Create dev environment in GPU mode with specified CUDA version,
-g Create dev environment in GPU mode with specified CUDA version,
supported:
$CUDA_VERSIONS
.
supported:
$
{
CUDA_VERSIONS
}
.
EOF
EOF
}
}
validate
()
{
validate
()
{
values
=
$(
echo
"
$1
"
|
tr
","
"
\n
"
)
values
=
$(
echo
"
$1
"
|
tr
","
"
\n
"
)
for
value
in
$values
for
value
in
$
{
values
}
do
do
if
[[
"
$value
"
==
$2
]]
;
then
if
[[
"
$
{
value
}
"
==
$2
]]
;
then
return
0
return
0
fi
fi
done
done
...
@@ -34,18 +34,18 @@ validate() {
...
@@ -34,18 +34,18 @@ validate() {
confirm
()
{
confirm
()
{
echo
"Continue? [yes/no]:"
echo
"Continue? [yes/no]:"
read
confirm
read
confirm
if
[[
!
$confirm
==
"yes"
]]
;
then
if
[[
!
$
{
confirm
}
==
"yes"
]]
;
then
exit
0
exit
0
fi
fi
}
}
# Pars
ing
flags.
# Pars
e
flags.
while
getopts
"cg:h"
flag
;
do
while
getopts
"cg:h"
flag
;
do
if
[[
$flag
==
"c"
]]
;
then
if
[[
$
{
flag
}
==
"c"
]]
;
then
cpu
=
1
cpu
=
1
elif
[[
$flag
==
"g"
]]
;
then
elif
[[
$
{
flag
}
==
"g"
]]
;
then
gpu
=
$OPTARG
gpu
=
$
{
OPTARG
}
elif
[[
$flag
==
"h"
]]
;
then
elif
[[
$
{
flag
}
==
"h"
]]
;
then
usage
usage
exit
0
exit
0
else
else
...
@@ -54,24 +54,24 @@ while getopts "cg:h" flag; do
...
@@ -54,24 +54,24 @@ while getopts "cg:h" flag; do
fi
fi
done
done
if
[[
-n
$gpu
&&
$cpu
-eq
1
]]
;
then
if
[[
-n
$
{
gpu
}
&&
$
{
cpu
}
-eq
1
]]
;
then
echo
"Only one mode can be specified."
echo
"Only one mode can be specified."
exit
1
exit
1
fi
fi
if
[[
-z
$gpu
&&
-z
$cpu
]]
;
then
if
[[
-z
$
{
gpu
}
&&
-z
$
{
cpu
}
]]
;
then
usage
usage
exit
1
exit
1
fi
fi
# Set up CPU mode.
# Set up CPU mode.
if
[[
$cpu
-eq
1
]]
;
then
if
[[
$
{
cpu
}
-eq
1
]]
;
then
torchversion
=
${
TORCH_VERSION
}
"+cpu"
torchversion
=
${
TORCH_VERSION
}
"+cpu"
name
=
"dgl-dev-cpu"
name
=
"dgl-dev-cpu"
fi
fi
# Set up GPU mode.
# Set up GPU mode.
if
[[
-n
$gpu
]]
;
then
if
[[
-n
$
{
gpu
}
]]
;
then
if
!
validate
${
CUDA_VERSIONS
}
${
gpu
}
;
then
if
!
validate
${
CUDA_VERSIONS
}
${
gpu
}
;
then
echo
"Error: Invalid CUDA version."
echo
"Error: Invalid CUDA version."
usage
usage
...
@@ -86,27 +86,27 @@ if [[ -n $gpu ]]; then
...
@@ -86,27 +86,27 @@ if [[ -n $gpu ]]; then
fi
fi
echo
"Confirm you are excuting the script from your DGL root directory."
echo
"Confirm you are excuting the script from your DGL root directory."
echo
"Current working directory:
$PWD
"
echo
"Current working directory:
$
{
PWD
}
"
confirm
confirm
# Prepare the conda environment yaml file.
# Prepare the conda environment yaml file.
rand
=
$(
echo
"
$RANDOM
"
|
md5sum
|
head
-c
20
)
rand
=
$(
echo
"
$
{
RANDOM
}
"
|
md5sum
|
head
-c
20
)
mkdir
-p
/tmp/
$rand
mkdir
-p
/tmp/
$
{
rand
}
cp
script/dgl_dev.yml.template /tmp/
$rand
/dgl_dev.yml
cp
script/dgl_dev.yml.template /tmp/
$
{
rand
}
/dgl_dev.yml
sed
-i
"s|__NAME__|
$name
|g"
/tmp/
$rand
/dgl_dev.yml
sed
-i
"s|__NAME__|
$
{
name
}
|g"
/tmp/
$
{
rand
}
/dgl_dev.yml
sed
-i
"s|__TORCH_VERSION__|
$torchversion
|g"
/tmp/
$rand
/dgl_dev.yml
sed
-i
"s|__TORCH_VERSION__|
$
{
torchversion
}
|g"
/tmp/
$
{
rand
}
/dgl_dev.yml
sed
-i
"s|__DGL_HOME__|
$PWD
|g"
/tmp/
$rand
/dgl_dev.yml
sed
-i
"s|__DGL_HOME__|
$
{
PWD
}
|g"
/tmp/
$
{
rand
}
/dgl_dev.yml
# Ask for final confirmation.
# Ask for final confirmation.
echo
"--------------------------------------------------"
echo
"--------------------------------------------------"
cat
/tmp/
$rand
/dgl_dev.yml
cat
/tmp/
$
{
rand
}
/dgl_dev.yml
echo
"--------------------------------------------------"
echo
"--------------------------------------------------"
echo
"Create a conda enviroment with the config?"
echo
"Create a conda enviroment with the config?"
confirm
confirm
# Create conda environment.
# Create conda environment.
conda
env
create
-f
/tmp/
$rand
/dgl_dev.yml
conda
env
create
-f
/tmp/
$
{
rand
}
/dgl_dev.yml
# Clean up created tmp conda environment yaml file.
# Clean up created tmp conda environment yaml file.
rm
-rf
/tmp/
$rand
rm
-rf
/tmp/
$
{
rand
}
exit
0
exit
0
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