पिप के साथ स्थापना
चलाकर TensorFlow निर्णय वन स्थापित करें:
# Install TensorFlow Decision Forests.
pip3 install tensorflow_decision_forests --upgrade
फिर, चलाकर स्थापना की जाँच करें:
# Check the version of TensorFlow Decision Forests.
python3 -c "import tensorflow_decision_forests as tfdf; print('Found TF-DF v' + tfdf.__version__)"
स्रोत से बनाएँ
लिनक्स
स्थापित करना
आवश्यकताएं
- बज़ेल >= 3.7.2
- पायथन> = 3
- गिट
- पायथन पैकेज: सुन्न टेन्सरफ़्लो पांडा
निर्भरताओं को हाथों से स्थापित करने के बजाय, आप TensorFlow Build docker का उपयोग कर सकते हैं। यदि आप यह विकल्प चुनते हैं, तो डॉकर इंस्टॉल करें:
- डॉकटर ।
संकलन
TensorFlow निर्णय वन इस प्रकार डाउनलोड करें:
# Download the source code of TF-DF.
git clone https://github.com/tensorflow/decision-forests.git
cd decision-forests
वैकल्पिक: TensorFlow निर्णय वन Yggdrasil निर्णय वन पर निर्भर करता है। यदि आप Yggdrasil कोड को संपादित करना चाहते हैं, तो आप Yggdrasil github को क्लोन कर सकते हैं और उसके अनुसार third_party/yggdrasil_decision_forests/workspace.bzl
में पथ बदल सकते हैं।
वैकल्पिक: यदि आप docker विकल्प का उपयोग करना चाहते हैं, तो start_compile_docker.sh
स्क्रिप्ट चलाएँ और अगले चरण पर जाएँ। यदि आप डॉकर विकल्प का उपयोग नहीं करना चाहते हैं, तो सीधे अगले चरण पर जाएं।
# Optional: Install and start the build docker.
./tools/start_compile_docker.sh
निम्नलिखित कमांड के साथ TF-DF के यूनिट टेस्ट को कंपाइल और रन करें। ध्यान दें कि test_bazel.sh
python3.8
और आपकी मशीन पर डिफ़ॉल्ट कंपाइलर के लिए कॉन्फ़िगर किया गया है। इस कॉन्फ़िगरेशन को बदलने के लिए फ़ाइल को सीधे संपादित करें।
# Build and test TF-DF.
./tools/test_bazel.sh
निम्नलिखित कमांड के साथ एक पिप पैकेज बनाएं और उसका परीक्षण करें। आप जिस अजगर का उपयोग करना चाहते हैं, उसके संस्करण के द्वारा python3.8 को बदलें। ध्यान दें कि आपको Python के उसी संस्करण का उपयोग करने की आवश्यकता नहीं है जैसा कि test_bazel.sh
स्क्रिप्ट में है।
यदि आपका कॉन्फ़िगरेशन manylinux2014 के साथ संगत है, तो एक manylinux2014
संगत पाइप पैकेज तैयार किया जाएगा।
यदि आपका कॉन्फ़िगरेशन manylinux2014 के साथ संगत नहीं है, तो एक गैर- manylinux2014
संगत पाइप पैकेज तैयार किया जाएगा, और अंतिम जाँच विफल हो जाएगी। इससे कोई फर्क नहीं पड़ता कि आप अपनी मशीन पर TF-DF का उपयोग करना चाहते हैं या नहीं। बिल्ड manylinux2014 को संगत बनाने का एक आसान तरीका ऊपर बताए गए डॉकटर का उपयोग करना है।
# Build and test a Pip package.
./tools/build_pip_package.sh python3.8
यह आदेश TF-DF पाइप पैकेज स्थापित करेगा और examples/minimal.py
में उदाहरण चलाएगा। पिप पैकेज dist/
निर्देशिका में स्थित है।
यदि आप पायथन के अन्य संगत संस्करण के लिए एक पिप पैकेज बनाना चाहते हैं, तो दौड़ें:
# Install the other versions of python (assume only python3.8 is installed; this is the case in the build docker).
sudo apt-get update && sudo apt-get install python3.7 python3.9 python3-pip
# Create the Pip package for the other version of python
./tools/build_pip_package.sh python3.7
./tools/build_pip_package.sh python3.9
वैकल्पिक रूप से , आप निम्न कमांड चलाकर पायनव का उपयोग करके अजगर के सभी संगत संस्करण के लिए पाइप पैकेज बना सकते हैं। अधिक जानकारी के लिए tools/build_pip_package.sh
का हेडर देखें।
# Build and test all the Pip package using Pyenv.
./tools/build_pip_package.sh ALL_VERSIONS
मैक ओएस
स्थापित करना
आवश्यकताएं
- एक्सकोड कमांड लाइन टूल्स
- बज़ेल (अनुशंसित बज़ेलिस्क )
- पायथन> = 3.8
- गिट
- Pyenv (कई पायथन संस्करणों के साथ पिप संकुल के निर्माण के लिए)
बिल्डिंग / पैकेजिंग (Apple CPU)
यदि आपके पास Apple CPU के साथ MacOS मशीन है, तो आप निम्न निर्देशों के साथ निर्माण कर सकते हैं।
तीन रिपॉजिटरी को क्लोन करें और पथ समायोजित करें।
git clone https://github.com/tensorflow/decision-forests.git git clone https://github.com/google/yggdrasil-decision-forests.git git clone --branch boost-1.75.0 https://github.com/boostorg/boost.git (cd boost && git submodule update --init --checkout --force) # Adjust path TF-DF --> YDF perl -0777 -i.original -pe 's/ http_archive\(\n name = "ydf",\n urls = \["https:\/\/github.com\/google\/yggdrasil-decision-forests\/archive\/refs\/heads\/main.zip"\],\n strip_prefix = "yggdrasil-decision-forests-main",\n \)/ native.local_repository\(\n name = "ydf",\n path = "..\/yggdrasil-decision-forests",\n \)/igs' decision-forests/third_party/yggdrasil_decision_forests/workspace.bzl # Adjust path YDF --> Boost perl -0777 -i.original -pe 's/ new_git_repository\(\n name = "org_boost",\n branch = branch,\n build_file_content = build_file_content,\n init_submodules = True,\n recursive_init_submodules = True,\n remote = "https:\/\/github.com\/boostorg\/boost",\n \)/ native.new_local_repository\(\n name = "org_boost",\n path = "..\/boost",\n build_file_content = build_file_content,\n \)/igs' yggdrasil-decision-forests/third_party/boost/workspace.bzl
Tensorflow कमिट हैश को ठीक करने के लिए आपको test_bazel.sh स्क्रिप्ट को मैन्युअल रूप से समायोजित करने की आवश्यकता हो सकती है, क्योंकि यह कभी-कभी MacOS बिल्ड के लिए टूट जाती है।
(वैकल्पिक) एक नया आभासी वातावरण बनाएं और इसे सक्रिय करें
python3 -m venv venv source venv/source/activate
Apple CPU के लिए TensorFlow डिपेंडेंसी को एडजस्ट करें
perl -0777 -i.original -pe 's/tensorflow~=/tensorflow-macos~=/igs' decision-forests/configure/setup.py
तय करें कि आप किस पायथन संस्करण का उपयोग करना और चलाना चाहते हैं
cd decision-forests # This will compile with the latest Tensorflow version in the tensorflow-macos repository. RUN_TESTS=1 PY_VERSION=3.9 TF_VERSION=mac-arm64 ./tools/test_bazel.sh
पिप पैकेज बनाएँ
# First, we deactivate our virtualenv, since the Pip script uses a different one. deactivate # Build the packages. ./tools/build_pip_package.sh ALL_VERSIONS_MAC_ARM64
पैकेज
decision-forests/dist/
में मिल सकते हैं।
इंटेल सीपीयू के लिए क्रॉस-कंपाइलिंग
यदि आपके पास Apple CPU के साथ एक MacOS मशीन है, तो Intel CPU के साथ MacOS मशीनों के लिए TF-DF को निम्न प्रकार से क्रॉस-कंपाइल करें।
Apple CPUs के लिए गाइड के चरण 1-3 और 5 का पालन करें, चरण 4 को छोड़ दें । आपको अपनी बिल्ड डायरेक्टरी को साफ़ करने के लिए
bazel --bazelrc=tensorflow_bazelrc clean --expunge
चलाने की आवश्यकता हो सकती है।तय करें कि आप किस पायथन संस्करण का उपयोग करना और चलाना चाहते हैं
cd decision-forests # This will compile with the latest Tensorflow version in the tensorflow-macos repository. RUN_TESTS=0 PY_VERSION=3.9 TF_VERSION=mac-intel-crosscompile ./tools/test_bazel.sh
पिप पैकेज बनाएँ
# First, we deactivate our virtualenv, since the Pip script uses a different one. deactivate # Build the packages. ./tools/build_pip_package.sh ALL_VERSIONS_MAC_INTEL_CROSSCOMPILE
पैकेज
decision-forests/dist/
में मिल सकते हैं।
अंतिम नोट
TF-DF का संकलन TensorFlow Pip पैकेज और TensorFlow Bazel निर्भरता पर निर्भर करता है। TensorFlow का केवल एक छोटा सा हिस्सा संकलित किया जाएगा। एक शक्तिशाली वर्कस्टेशन पर TF-DF को कंपाइल करने में ~10 मिनट लगते हैं।