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
chenpangpang
gpu-base-image-build
Commits
3b1f8b16
Commit
3b1f8b16
authored
Sep 18, 2024
by
chenpangpang
Browse files
feat: build_ubuntu.sh update
parent
e9241c46
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
11 deletions
+21
-11
build_space/build_ubuntu.sh
build_space/build_ubuntu.sh
+21
-11
No files found.
build_space/build_ubuntu.sh
View file @
3b1f8b16
#/bin/bash
# pytorch==2.2.1 torchvision==0.17.1 torchaudio==2.2.1 pytorch-cuda=12.1
# cuda=11.6(这个版本的空镜像,有些框架需要低版本)
# paddlepaddle-gpu==2.6.1.post120 cuda12
# tensroflow 安装最高版本 cuda12
rm
-r
./tmp
#!/bin/bash
# 框架
framework
=
$1
newtag
=
$2
# 输出镜像tag
image_tag
=
$2
# 基础镜像
base_image
=
$3
build_args
=
" --build-arg BASE_IMAGE=
$base_image
"
if
[
${
base_image
%%
:
*
}
=
"pytorch/pytorch"
]
;
then
build_args
=
"
$build_args
--build-arg BASE_IMAGE_IS_TORCH=1 "
fi
for
arg
in
${
*
:4
}
do
build_args
=
"
$build_args
--build-arg
$arg
"
done
tmp_dockerfile
=
"Dockerfile.
${
RANDOM
}
"
if
[
!
-d
"./tmp"
]
;
then
...
...
@@ -28,10 +34,14 @@ cp ./python-requirements.txt ./tmp/
cp
-f
./Dockerfile.
${
framework
}
_ubuntu ./tmp/
${
tmp_dockerfile
}
# temp_image="$(grep -n '^FROM' ./tmp/${tmp_dockerfile} | tac | head -1 | awk '{print $2}')"
# sed -i "s?${temp_image}?${base_tag}?g" ./tmp/${tmp_dockerfile}
docker build
-f
./tmp/
${
tmp_dockerfile
}
-t
${
newtag
}
./tmp/
# docker build --build-arg BASE_IMAGE_IS_TORCH=1 --build-arg IMAGE="pytorch/pytorch:2.3.1-cuda12.1-cudnn8-runtime" -f ./tmp/${tmp_dockerfile} -t ${newtag} ./tmp/
echo
"docker build -f ./tmp/
${
tmp_dockerfile
}
-t
${
image_tag
}
$build_args
./tmp/"
docker build
-f
./tmp/
${
tmp_dockerfile
}
-t
${
image_tag
}
$build_args
./tmp/
#echo "docker build -f ./tmp/${tmp_dockerfile} -t ${image_tag} $build_args ./tmp/"
rm
-r
./tmp
if
[[
$?
-eq
0
]]
;
then
echo
-e
"
\0
33[32mBuild Image Successfully !
\0
33[0m"
else
echo
-e
"
\0
33[32mBuild Image
unsuccessful
!
\0
33[0m"
echo
-e
"
\0
33[32mBuild Image
fail
!
\0
33[0m"
exit
1
fi
\ No newline at end of file
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