Skip to content

Commit ec4ed25

Browse files
committed
Initial commit
1 parent fa3e7a5 commit ec4ed25

7 files changed

+244
-2
lines changed

Makefile

+134
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
PORTNAME= libtensorflow1
2+
DISTVERSIONPREFIX= v
3+
DISTVERSION= 1.15.5
4+
DISTVERSIONSUFFIX=
5+
CATEGORIES= science
6+
7+
MAINTAINER= [email protected]
8+
COMMENT= C API for TensorFlow, an open source platform for machine learning
9+
10+
LICENSE= APACHE20 THIRD_PARTY_TF_C_LICENSES
11+
LICENSE_COMB= multi
12+
LICENSE_NAME_THIRD_PARTY_TF_C_LICENSES= Third-Party TensorFlow C Licenses
13+
LICENSE_FILE_APACHE20= ${WRKSRC}/LICENSE
14+
LICENSE_FILE_THIRD_PARTY_TF_C_LICENSES= ${WRKDIR}/THIRD_PARTY_TF_C_LICENSES
15+
LICENSE_PERMS_THIRD_PARTY_TF_C_LICENSES= dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
16+
17+
CONFLICTS_INSTALL= science/libtensorflow2
18+
19+
ONLY_FOR_ARCHS= amd64
20+
21+
BUILD_DEPENDS= bash:shells/bash \
22+
bazel:devel/bazel029 \
23+
git:devel/git
24+
25+
USES= gmake python:3.7-3.9,build
26+
BINARY_ALIAS= python3=${PYTHON_CMD}
27+
BINARY_ALIAS+= python=${PYTHON_CMD}
28+
29+
USE_GITHUB= yes
30+
GH_ACCOUNT= tensorflow
31+
GH_PROJECT= tensorflow
32+
33+
USE_LDCONFIG= yes
34+
35+
OPTIONS_DEFINE= CUDA ROCM XLA
36+
37+
OPTIONS_SINGLE= CPUFEATURE
38+
OPTIONS_SINGLE_CPUFEATURE= NOAVX AVX AVX2
39+
40+
NOAVX_DESC= Disable Advanced Vector Extensions
41+
AVX_DESC= Enable Advanced Vector Extensions (AVX)
42+
AVX2_DESC= Enable Advanced Vector Extensions v2 (AVX2)
43+
44+
NOAVX_VARS= BAZEL_ARGS=""
45+
AVX_VARS= BAZEL_ARGS="--copt=-march=core-avx-i --host_copt=-march=core-avx-i"
46+
AVX2_VARS= BAZEL_ARGS="--copt=-march=core-avx2 --host_copt=-march=core-avx2"
47+
48+
CUDA_DESC= Enable Compute Unified Device Architecture (CUDA) for Nvidia GPUs
49+
CUDA_VARS= TF_ENABLE_CUDA=1
50+
CUDA_VARS_OFF= TF_ENABLE_CUDA=0
51+
52+
ROCM_DESC= Enable Radeon Open Computer (ROCm) for AMD GPUs
53+
ROCM_VARS= TF_ENABLE_ROCM=1
54+
ROCM_VARS_OFF= TF_ENABLE_ROCM=0
55+
56+
XLA_DESC= Enable Accelerated Linear Algebra (XLA)
57+
XLA_VARS= TF_ENABLE_XLA=1
58+
XLA_VARS_OFF= TF_ENABLE_XLA=0
59+
60+
OPTIONS_DEFAULT= AVX
61+
62+
BAZEL_OPTS= --output_user_root=${WRKDIR}/bazel_out
63+
CC?= clang
64+
65+
post-extract:
66+
# THIRD_PARTY_TF_C_LICENSES is generated as a Bazel build target (see
67+
# //tensorflow/tools/lib_package:clicenses) and the empty file written
68+
# here will be overwritten. Creation of this file is to satisfy checks.
69+
@${TOUCH} ${WRKDIR}/THIRD_PARTY_TF_C_LICENSES
70+
71+
do-configure:
72+
@cd ${WRKSRC} && ${SETENV} \
73+
CC_OPT_FLAGS="-I${LOCALBASE}/include" \
74+
PREFIX="${LOCALBASE}" \
75+
PYTHON_BIN_PATH=${PYTHON_CMD} \
76+
PYTHON_LIB_PATH="${PYTHON_SITELIBDIR}" \
77+
TF_CONFIGURE_IOS=0 \
78+
TF_DOWNLOAD_CLANG=0 \
79+
TF_ENABLE_XLA=${TF_ENABLE_XLA} \
80+
TF_IGNORE_MAX_BAZEL_VERSION=0 \
81+
TF_NEED_CUDA=${TF_ENABLE_CUDA} \
82+
TF_NEED_ROCM=${TF_ENABLE_ROCM} \
83+
TF_NEED_TENSORRT=0 \
84+
TF_SET_ANDROID_WORKSPACE=0 \
85+
${LOCALBASE}/bin/bash ./configure
86+
87+
do-build:
88+
@cd ${WRKSRC} && ${LOCALBASE}/bin/bazel ${BAZEL_OPTS} build \
89+
${BAZEL_ARGS} \
90+
--action_env=PATH=${PATH} \
91+
--local_cpu_resources=${MAKE_JOBS_NUMBER} \
92+
--noshow_loading_progress \
93+
--noshow_progress \
94+
--subcommands \
95+
--verbose_failures \
96+
//tensorflow/tools/lib_package:clicenses_generate \
97+
//tensorflow/tools/lib_package:libtensorflow.tar.gz
98+
99+
do-test:
100+
@cd ${WRKSRC} && ${LOCALBASE}/bin/bazel ${BAZEL_OPTS} test \
101+
${BAZEL_ARGS} \
102+
--action_env=PATH=${PATH} \
103+
--local_cpu_resources=${MAKE_JOBS_NUMBER} \
104+
--noshow_loading_progress \
105+
--noshow_progress \
106+
--subcommands \
107+
--test_env=CC=${CC} \
108+
--verbose_failures \
109+
//tensorflow/tools/lib_package:libtensorflow_test
110+
111+
pre-install:
112+
@${CP} ${WRKSRC}/bazel-bin/tensorflow/tools/lib_package/THIRD_PARTY_TF_C_LICENSES ${WRKDIR}/THIRD_PARTY_TF_C_LICENSES
113+
@${MKDIR} ${WRKDIR}/lib_package
114+
@tar xz -C ${WRKDIR}/lib_package -f ${WRKSRC}/bazel-bin/tensorflow/tools/lib_package/libtensorflow.tar.gz
115+
${MKDIR} ${STAGEDIR}${PREFIX}/include/tensorflow
116+
${MKDIR} ${STAGEDIR}${PREFIX}/include/tensorflow/c
117+
${MKDIR} ${STAGEDIR}${PREFIX}/include/tensorflow/c/eager
118+
119+
do-install:
120+
${INSTALL_DATA} ${WRKDIR}/lib_package/include/tensorflow/c/c_api_experimental.h ${STAGEDIR}${PREFIX}/include/tensorflow/c/c_api_experimental.h
121+
${INSTALL_DATA} ${WRKDIR}/lib_package/include/tensorflow/c/c_api.h ${STAGEDIR}${PREFIX}/include/tensorflow/c/c_api.h
122+
${INSTALL_DATA} ${WRKDIR}/lib_package/include/tensorflow/c/eager/c_api.h ${STAGEDIR}${PREFIX}/include/tensorflow/c/eager/c_api.h
123+
${INSTALL_DATA} ${WRKDIR}/lib_package/include/tensorflow/c/tf_attrtype.h ${STAGEDIR}${PREFIX}/include/tensorflow/c/tf_attrtype.h
124+
${INSTALL_DATA} ${WRKDIR}/lib_package/include/tensorflow/c/tf_datatype.h ${STAGEDIR}${PREFIX}/include/tensorflow/c/tf_datatype.h
125+
${INSTALL_DATA} ${WRKDIR}/lib_package/include/tensorflow/c/tf_status.h ${STAGEDIR}${PREFIX}/include/tensorflow/c/tf_status.h
126+
${INSTALL_DATA} ${WRKDIR}/lib_package/include/tensorflow/c/tf_tensor.h ${STAGEDIR}${PREFIX}/include/tensorflow/c/tf_tensor.h
127+
${INSTALL_PROGRAM} ${WRKDIR}/lib_package/lib/libtensorflow.so.${DISTVERSION} ${STAGEDIR}${PREFIX}/lib/libtensorflow.so.${DISTVERSION}
128+
${INSTALL_PROGRAM} ${WRKDIR}/lib_package/lib/libtensorflow_framework.so.${DISTVERSION} ${STAGEDIR}${PREFIX}/lib/libtensorflow_framework.so.${DISTVERSION}
129+
@${RLN} ${STAGEDIR}${PREFIX}/lib/libtensorflow.so.${DISTVERSION} ${STAGEDIR}${PREFIX}/lib/libtensorflow.so.1
130+
@${RLN} ${STAGEDIR}${PREFIX}/lib/libtensorflow.so.1 ${STAGEDIR}${PREFIX}/lib/libtensorflow.so
131+
@${RLN} ${STAGEDIR}${PREFIX}/lib/libtensorflow_framework.so.${DISTVERSION} ${STAGEDIR}${PREFIX}/lib/libtensorflow_framework.so.1
132+
@${RLN} ${STAGEDIR}${PREFIX}/lib/libtensorflow_framework.so.1 ${STAGEDIR}${PREFIX}/lib/libtensorflow_framework.so
133+
134+
.include <bsd.port.mk>

README.md

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,19 @@
1-
# libtensorflow1-freebsd-port
2-
FreeBSD port for Tensorflow 1.15
1+
FreeBSD port for Tensorflow 1.15
2+
3+
This provides an easy to use copy of *science/libtensorflow1* until the port is
4+
committed to the repository.
5+
6+
You can follow the port progress in [bug
7+
260694](https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=260694)
8+
9+
# Usage
10+
11+
```
12+
cd /usr/ports/science
13+
git clone https://github.com/psa/libtensorflow1-freebsd-port libtensorflow1
14+
cd libtensorflow1
15+
make package
16+
```
17+
18+
This takes a long time to build (~90 minutes with 4 Xeon E31275 @ 3.40GHz
19+
cores) and 8 GiB of RAM.

distinfo

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
TIMESTAMP = 1640438990
2+
SHA256 (tensorflow-tensorflow-v1.15.5_GH0.tar.gz) = 4c4d23e311093ded2d2e287b18d7c45b07b5984ab88a1d2f91f8f13c886123db
3+
SIZE (tensorflow-tensorflow-v1.15.5_GH0.tar.gz) = 46212258

files/patch-.bazelrc

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
--- .bazelrc.orig 2021-01-04 20:18:42.000000000 +0000
2+
+++ .bazelrc 2021-12-25 17:26:39.181508000 +0000
3+
@@ -195,7 +195,7 @@
4+
build:c++1z --config=c++17
5+
6+
# Default paths for TF_SYSTEM_LIBS
7+
-build --define=PREFIX=/usr
8+
+build --define=PREFIX=/usr/local
9+
build --define=LIBDIR=$(PREFIX)/lib
10+
build --define=INCLUDEDIR=$(PREFIX)/include
11+
12+
@@ -208,6 +208,9 @@
13+
# Instruction set optimizations
14+
# TODO(gunan): Create a feature in toolchains for avx/avx2 to
15+
# avoid having to define linux/win separately.
16+
+build:avx_freebsd --copt=-mavx
17+
+build:avx2_freebsd --copt=-mavx2
18+
+build:native_arch_freebsd --copt=-march=native
19+
build:avx_linux --copt=-mavx
20+
build:avx2_linux --copt=-mavx2
21+
build:native_arch_linux --copt=-march=native
22+
@@ -295,6 +298,20 @@
23+
build:rbe_linux_py3 --python_path="/usr/bin/python3"
24+
build:rbe_linux_py3 --repo_env=TF_PYTHON_CONFIG_REPO="@org_tensorflow//third_party/toolchains/preconfig/ubuntu16.04/py3"
25+
26+
+build:rbe_cpu_freebsd --config=rbe_cpu_linux
27+
+build:rbe_freebsd_cuda_nvcc --config=rbe_linux_cuda_nvcc
28+
+common:rbe_gpu_freebsd --config=rbe_gpu_linux
29+
+
30+
+build:rbe_freebsd_py2 --config=rbe_linux
31+
+build:rbe_freebsd_py2 --repo_env=PYTHON_BIN_PATH="/usr/local/bin/python2"
32+
+build:rbe_freebsd_py2 --python_path="/usr/local/bin/python2"
33+
+build:rbe_freebsd_py2 --repo_env=TF_PYTHON_CONFIG_REPO="@org_tensorflow//third_party/toolchains/preconfig/ubuntu16.04/py"
34+
+
35+
+build:rbe_freebsd_py3 --config=rbe_linux
36+
+build:rbe_freebsd_py3 --repo_env=PYTHON_BIN_PATH="/usr/local/bin/python3"
37+
+build:rbe_freebsd_py3 --python_path="/usr/local/bin/python3"
38+
+build:rbe_freebsd_py3 --repo_env=TF_PYTHON_CONFIG_REPO="@org_tensorflow//third_party/toolchains/preconfig/ubuntu16.04/py3"
39+
+
40+
build:rbe_win --config=rbe
41+
build:rbe_win --crosstool_top="@org_tensorflow//third_party/toolchains/preconfig/win_1803/bazel_026:toolchain"
42+
build:rbe_win --extra_execution_platforms="@org_tensorflow//third_party/toolchains/preconfig/win_1803:rbe_windows_1803"
43+
@@ -334,6 +351,9 @@
44+
build:tensorflow_testing_rbe_linux --config=tensorflow_testing_rbe
45+
build:tensorflow_testing_rbe_linux --config=rbe
46+
build:tensorflow_testing_rbe_linux --config=rbe_linux
47+
+
48+
+common:tensorflow_testing_rbe_freebsd --config=tensorflow_testing_rbe_linux
49+
+build:tensorflow_testing_rbe_freebsd --config=tensorflow_testing_rbe_linux
50+
51+
common:tensorflow_testing_rbe_win --remote_instance_name=projects/tensorflow-testing/instances/windows
52+
build:tensorflow_testing_rbe_win --config=tensorflow_testing_rbe

files/patch-configure.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- configure.py.orig 2021-12-25 17:58:29.902610000 +0000
2+
+++ configure.py 2021-12-25 17:59:34.301740000 +0000
3+
@@ -475,7 +475,7 @@
4+
print('Cannot find bazel. Please install bazel.')
5+
sys.exit(0)
6+
curr_version = run_shell(
7+
- ['bazel', '--batch', '--bazelrc=/dev/null', 'version'])
8+
+ ['bazel', '--batch', '--output_user_root=/tmp/.bazel', '--bazelrc=/dev/null', 'version'])
9+
10+
for line in curr_version.split('\n'):
11+
if 'Build label: ' in line:

pkg-descr

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
TensorFlow is an end-to-end open source platform for machine learning. It has a
2+
comprehensive, flexible ecosystem of tools, libraries, and community resources
3+
that lets researchers push the state-of-the-art in ML and developers easily
4+
build and deploy ML-powered applications. The TensorFlow C API is typically a
5+
requirement of TensorFlow APIs in other languages such as Go and Rust.
6+
7+
This is version 1 of the API, which is deprecated but still widely used.
8+
9+
WWW: https://www.tensorflow.org/install/lang_c

pkg-plist

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@dir include/tensorflow
2+
@dir include/tensorflow/c
3+
@dir include/tensorflow/c/eager
4+
include/tensorflow/c/c_api_experimental.h
5+
include/tensorflow/c/c_api.h
6+
include/tensorflow/c/eager/c_api.h
7+
include/tensorflow/c/tf_attrtype.h
8+
include/tensorflow/c/tf_datatype.h
9+
include/tensorflow/c/tf_status.h
10+
include/tensorflow/c/tf_tensor.h
11+
lib/libtensorflow.so
12+
lib/libtensorflow.so.1
13+
lib/libtensorflow.so.1.15.5
14+
lib/libtensorflow_framework.so
15+
lib/libtensorflow_framework.so.1
16+
lib/libtensorflow_framework.so.1.15.5

0 commit comments

Comments
 (0)