Skip to content

Commit 614eccf

Browse files
authored
[one-cmds] Support ubuntu 24.04 (#14526)
This commit updates cmake to support ubuntu 24.04. ONE-DCO-1.0-Signed-off-by: Hyeongseok Oh <[email protected]>
1 parent d978911 commit 614eccf

File tree

2 files changed

+140
-14
lines changed

2 files changed

+140
-14
lines changed

compiler/one-cmds/CMakeLists.txt

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,43 @@
22
# Ubuntu18.04; explictly installed python3.8 (default is python3.6)
33
# Ubuntu20.04; default python3.8
44
# Ubuntu22.04; default python3.10
5+
# Ubuntu24.04; explicitly installed python3.8 (default is python3.12)
56
# refer https://github.com/Samsung/ONE/issues/9962
6-
find_package(PythonInterp 3.8 QUIET)
7-
find_package(PythonLibs 3.8 QUIET)
8-
9-
if(NOT ${PYTHONINTERP_FOUND})
10-
message(STATUS "Build one-cmds: FALSE (Python3 is missing)")
11-
return()
12-
endif()
13-
14-
if(${PYTHON_VERSION_MINOR} LESS 8)
15-
message(STATUS "Build one-cmds: FALSE (You need to install Python version higher than 3.8)")
16-
return()
7+
if(CMAKE_VERSION VERSION_LESS 3.12)
8+
find_package(PythonInterp 3.8 QUIET)
9+
find_package(PythonLibs 3.8 QUIET)
10+
11+
if(NOT ${PYTHONINTERP_FOUND})
12+
message(STATUS "Build one-cmds: FALSE (Python3 is missing)")
13+
return()
14+
endif()
15+
16+
if(${PYTHON_VERSION_MINOR} LESS 8)
17+
message(STATUS "Build one-cmds: FALSE (You need to install Python version higher than 3.8)")
18+
return()
19+
endif()
20+
else()
21+
find_package(Python 3.8 EXACT COMPONENTS Interpreter QUIET)
22+
if(NOT Python_FOUND)
23+
find_package(Python 3.8 COMPONENTS Interpreter QUIET)
24+
endif()
25+
26+
# tensorflow 2.12.1 supports Python 3.8 ~ 3.11
27+
if(Python_VERSION VERSION_GREATER_EQUAL 3.12)
28+
message(STATUS "Build one-cmds: FALSE (Python version 3.12 or higher is not supported yet)")
29+
return()
30+
endif()
31+
if(Python_VERSION VERSION_LESS 3.8)
32+
message(STATUS "Build one-cmds: FAILED (Install Python version 3.8 or 3.10)")
33+
return()
34+
endif()
35+
36+
if(NOT Python_Interpreter_FOUND)
37+
message(STATUS "Build one-cmds: FAILED (Python3 is missing)")
38+
return()
39+
endif()
40+
41+
set(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
1742
endif()
1843

1944
# NOTE these files should not have extensions.
@@ -46,9 +71,13 @@ else(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "aarch64")
4671
# NOTE copy one-prepare-venv.u1804 as build/../one-prepare-venv
4772
# and install build/../one-prepare-venv file
4873
list(APPEND ONE_COMMAND_FILES one-prepare-venv.u1804)
49-
else(ONE_UBUNTU_CODENAME_BIONIC)
74+
elseif(ONE_UBUNTU_CODENAME_NOBLE)
75+
# NOTE copy one-prepare-venv.u2404 as build/../one-prepare-venv
76+
# and install build/../one-prepare-venv file
77+
list(APPEND ONE_COMMAND_FILES one-prepare-venv.u2404)
78+
else()
5079
list(APPEND ONE_COMMAND_FILES one-prepare-venv)
51-
endif(ONE_UBUNTU_CODENAME_BIONIC)
80+
endif()
5281
endif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "aarch64")
5382

5483
# pytorch importer is an experimental feature, it is not used in default configuration
@@ -78,7 +107,7 @@ foreach(ONE_COMMAND IN ITEMS ${ONE_COMMAND_FILES})
78107
GROUP_READ GROUP_EXECUTE
79108
WORLD_READ WORLD_EXECUTE
80109
DESTINATION bin)
81-
110+
82111
endforeach(ONE_COMMAND)
83112

84113
set(ONE_UTILITY_FILES
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/bin/bash
2+
3+
# Copyright (c) 2024 Samsung Electronics Co., Ltd. All Rights Reserved
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
set -e
18+
19+
DRIVER_PATH="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
20+
21+
VENV_ACTIVATE=${DRIVER_PATH}/venv/bin/activate
22+
# NOTE please use venv's python instead of python after `source activation`.
23+
# This script is called by debian maintainer script, i.e. `postinst`.
24+
# Since debian maintainer script is called with sudo, `source activation` is ignored.
25+
VENV_PYTHON=${DRIVER_PATH}/venv/bin/python
26+
27+
if [ ! -f ${VENV_ACTIVATE} ]; then
28+
# Create python virtual enviornment
29+
python3.8 -m venv "${DRIVER_PATH}/venv"
30+
fi
31+
32+
# NOTE version
33+
# - https://github.com/onnx/onnx/blob/master/docs/Versioning.md
34+
# - https://github.com/onnx/onnx-tensorflow/blob/master/Versioning.md
35+
36+
VER_TENSORFLOW=2.12.1
37+
VER_ONNX=1.16.0
38+
VER_ONNXRUNTIME=1.18.0
39+
VER_ONNX_TF=1.10.0
40+
VER_PYDOT=1.4.2
41+
VER_TORCH="2.1.2+cpu"
42+
43+
# Install tensorflow
44+
45+
PIP_TRUSTED_HOST="--trusted-host pypi.org "
46+
PIP_TRUSTED_HOST+="--trusted-host pypi.python.org "
47+
PIP_TRUSTED_HOST+="--trusted-host files.pythonhosted.org "
48+
PIP_TRUSTED_HOST+="--trusted-host download.pytorch.org "
49+
50+
PIP_TIMEOUT="--default-timeout=1000 "
51+
52+
PIP_OPTIONS="${PIP_TIMEOUT} ${PIP_TRUSTED_HOST}"
53+
54+
# NOTE $ONE_PREPVENV_PIP_OPTION is to provide additional PIP options
55+
# such as ceritificate file behind firewall
56+
# ex) ONE_PREPVENV_PIP_OPTION="--cert SomePrivateCetificate.crt" ./one-prepare-venv
57+
if [[ ! -z "$ONE_PREPVENV_PIP_OPTION" ]]; then
58+
PIP_OPTIONS+=" ${ONE_PREPVENV_PIP_OPTION} "
59+
fi
60+
61+
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install --upgrade pip setuptools
62+
if [ -n "${EXT_TENSORFLOW_WHL}" ]; then
63+
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install ${EXT_TENSORFLOW_WHL}
64+
else
65+
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install tensorflow-cpu==${VER_TENSORFLOW}
66+
fi
67+
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install Pillow
68+
# Fix version to that of TF release date
69+
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install tensorflow_probability==0.20.1
70+
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install tensorflow_addons==0.20.0
71+
72+
# Install PyTorch and ONNX related
73+
# NOTE set ONE_PREPVENV_TORCH_SOURCE to override options for source URL.
74+
TORCH_SOURCE_OPTION="-f https://download.pytorch.org/whl/torch_stable.html"
75+
if [[ ! -z "$ONE_PREPVENV_TORCH_SOURCE" ]]; then
76+
TORCH_SOURCE_OPTION="${ONE_PREPVENV_TORCH_SOURCE}"
77+
fi
78+
# TODO remove torch message
79+
echo "Torch from '${ONE_PREPVENV_TORCH_SOURCE}' -> '${TORCH_SOURCE_OPTION}'"
80+
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install torch==${VER_TORCH} ${TORCH_SOURCE_OPTION}
81+
82+
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install onnx==${VER_ONNX}
83+
84+
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install onnxruntime==${VER_ONNXRUNTIME}
85+
86+
# Provide install of custom onnx-tf
87+
if [ -n "${EXT_ONNX_TF_WHL}" ]; then
88+
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install ${EXT_ONNX_TF_WHL}
89+
else
90+
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install onnx-tf==${VER_ONNX_TF}
91+
fi
92+
93+
# Fix version to that of TF release date
94+
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install --upgrade protobuf==4.23.3
95+
96+
# Install pydot for visq
97+
${VENV_PYTHON} -m pip ${PIP_OPTIONS} install pydot==${VER_PYDOT}

0 commit comments

Comments
 (0)