APPFL: cannot run the command appfl-install-compressor

After installing appfl via running the following command pip install appfl I could not run appfl-install-compressor it says command not found

Environment: Ubuntu 20.04 Python 3.8.10

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 20 (10 by maintainers)

Most upvoted comments

I see, and I create the following short example for you to get started

import math
import torch
import torch.nn as nn
from appfl.config import Config
from appfl.compressor import Compressor

class CNN(nn.Module):
    def __init__(self, num_channel, num_classes, num_pixel):
        super().__init__()
        self.conv1 = nn.Conv2d(
            num_channel, 32, kernel_size=5, padding=0, stride=1, bias=True
        )
        self.conv2 = nn.Conv2d(32, 64, kernel_size=5, padding=0, stride=1, bias=True)
        self.maxpool = nn.MaxPool2d(kernel_size=(2, 2))
        self.act = nn.ReLU(inplace=True)

        ###
        ### X_out = floor{ 1 + (X_in + 2*padding - dilation*(kernel_size-1) - 1)/stride }
        ###
        X = num_pixel
        X = math.floor(1 + (X + 2 * 0 - 1 * (5 - 1) - 1) / 1)
        X = X / 2
        X = math.floor(1 + (X + 2 * 0 - 1 * (5 - 1) - 1) / 1)
        X = X / 2
        X = int(X)

        self.fc1 = nn.Linear(64 * X * X, 512)
        self.fc2 = nn.Linear(512, num_classes)

    def forward(self, x):
        x = self.act(self.conv1(x))
        x = self.maxpool(x)
        x = self.act(self.conv2(x))
        x = self.maxpool(x)
        x = torch.flatten(x, 1)
        x = self.act(self.fc1(x))
        x = self.fc2(x)
        return x

# get the compressor configuration
config = Config()
config.enable_compression = True
config.lossy_compressor = "SZ3"
config.error_bounding_mode = 'REL' # REL or ABS
config.error_bound = 1e-3
config.lossless_compressor = "blosc"
compressor = Compressor(config)

# create a model
cnn = CNN(3, 10, 32)

# compress the model
compressed_model, lossy_elements = compressor.compress_model(cnn.state_dict())

# decompress the model 
decompressed_model = compressor.decompress_model(compressed_model, cnn)

Yeah works for SZ2 ! Thank you so much @Zilinghan , I really appreciate your help regarding this. Have a nice one!

Ya, then that’s the problem - try to install a higher version CMake should resolve the problem. But anyway, it seems that the installation for SZ is successful. So you should run a simple example now by changing the compressor to SZ2. For example

config = Config()
config.enable_compression = True
config.lossy_compressor = "SZ2" # Change from SZ3 to SZ2
config.error_bounding_mode = 'REL' # REL or ABS
config.error_bound = 1e-3
config.lossless_compressor = "blosc"
compressor = Compressor(config)

Glad to help!