With your virtual environment activated, use pip to install Cifer:
bash
pipinstallcifer
This command will download and install Cifer along with all its dependencies, including the appropriate versions of TensorFlow and PyTorch for your system.
Tip: Install the Latest Version
To make sure you're installing the latest version of the package, use:
After the installation is complete, verify that Cifer has been installed correctly:
Method 1: Using Python
python
import ciferprint(cifer.__version__)
This should print the version number of the installed Cifer package.
CiferVersion1.0.21
Method 2: Using CLI
pipshowcifer
This will display the installed version and other metadata about the package.
Check FedLearn Functionality
To ensure that the FedLearn module is working correctly, you can run a quick test:
This will perform a series of checks to ensure all components are installed and configured correctly.
GPU/TPU Support Verification
If you're planning to use GPU or TPU acceleration, verify that Cifer can detect and use these resources:
These commands will provide information about the available GPU or TPU resources and confirm if Cifer can utilize them.
Troubleshooting
If you encounter any issues during installation:
Ensure your virtual environment is activated.
Check that you have the latest version of pip.
Verify that your system meets all the requirements listed in the previous sections.
If problems persist, consult the Cifer documentation or reach out to the support team.
With Cifer successfully installed, you're now ready to move on to the configuration stage and begin setting up your federated learning environment.
Install and Import Dependencies
While the Cifer package includes many core functionalities, some additional libraries need to be installed separately. Follow these steps to ensure all necessary dependencies are installed and imported correctly.
Install Additional Dependencies
Run the following command in your Jupyter notebook or terminal to install the required dependencies:
Import Dependencies
After installing the Cifer package, all necessary dependencies are included. Let's import and check these dependencies to ensure everything is set up correctly.
Import Core Dependencies
Run the following Python script to import the core dependencies and check their availability:
To check whether this Python file is supported by GPU/TPU, run the following command:
Expected output:
Check GPU/TPU Support (Optional)
For users planning to use GPUs or TPUs, you can check their availability:
For NVIDIA GPUs:
Run the following Python script to check CUDA availability:
For TPUs (Google Cloud):
If you're using Google Cloud TPUs, check TPU availability with:
Troubleshooting
If you encounter any issues while importing dependencies:
Ensure you've activated the virtual environment where Cifer is installed.
Verify that you have the latest version of Cifer:
For GPU-related issues, ensure your NVIDIA drivers and CUDA toolkit are up to date and compatible with the installed TensorFlow and PyTorch versions.
By running these import and check steps, you can confirm that all necessary dependencies for Cifer's FHE are correctly installed and ready to use, allowing you to proceed with your federated learning tasks.
# Import Cifer and core dependencies
import cifer
import torch
import torchvision
import tensorflow as tf
import numpy as np
import matplotlib.pyplot as plt
import grpc
import transformers
import sklearn
import pandas as pd
import cv2 # OpenCV
from PIL import Image # Pillow
from Crypto.Cipher import AES # PyCryptodome
from tqdm import tqdm
print(f"Cifer version: {cifer.__version__}")
print("All core dependencies successfully imported.")
# Check for GPU availability
if torch.cuda.is_available():
device = torch.device("cuda")
print(f"PyTorch is using GPU: {device}")
else:
device = torch.device("cpu")
print("PyTorch is using CPU")
# Check TensorFlow GPU availability
if tf.test.is_built_with_cuda():
print("TensorFlow is built with CUDA support")
print(f"TensorFlow GPU available: {tf.test.is_gpu_available()}")
else:
print("TensorFlow is not built with CUDA support")
python3 import_dependencies.py
Cifer Version 1.0.21
All core dependencies successfully imported.
PyTorch is using CPU
TensorFlow is not built with CUDA support
python
import subprocess
# Check CUDA version using nvidia-smi
try:
result = subprocess.run(['nvidia-smi'], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
cuda_version = result.stdout.decode('utf-8')
print("CUDA is available. nvidia-smi output:")
print(cuda_version)
except FileNotFoundError:
print("nvidia-smi command not found. CUDA might not be installed.")
python
import tensorflow as tf
print("Available TPU devices:")
print(tf.config.list_physical_devices('TPU'))